sqllineage/sqllineage.py
2025-02-27 19:05:15 +08:00

45 lines
1.2 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from flask import Flask, render_template, request, jsonify,send_file
from utils.sql_parse import parse_create_table_sql
from utils.log import Log
app = Flask(__name__)
log = Log().getlog()
@app.route('/')
def index():
return send_file('templates/index.html')
@app.route('/a')
def index_a():
return render_template('a.html')
@app.route('/b')
def index_b():
return render_template('b.html')
@app.route('/convert', methods=['POST'])
def convert_sql():
sql_input = request.form['sql']
if sql_input.strip() == '':
return jsonify({
'parsed_result': "请在上面输入框输入hologres建表语句",
'message': 'SQL processed.'
})
log.info("SQL Input: %s", sql_input)
try:
parsed_result = parse_create_table_sql(sql_input, '')
print(parsed_result)
result = {
'parsed_result': parsed_result,
'message': 'SQL processed successfully.'
}
except Exception as e:
result = {'error': f'请检查输入sql:\n\n {str(e)}'}
log.info("SQL result: %s", result)
return jsonify(result)
if __name__ == '__main__':
# 指定host和port这里使用0.0.0.0可以让服务器被外部访问
app.run(host='0.0.0.0', port=8778, debug=True)