This commit is contained in:
尹舟 2025-02-27 19:05:15 +08:00
parent 117e171255
commit 767d298af9
2 changed files with 16 additions and 13 deletions

@ -1,26 +1,22 @@
from flask import Flask, render_template, request, jsonify
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 render_template('index.html')
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']
@ -43,7 +39,6 @@ def convert_sql():
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)

@ -81,6 +81,14 @@
min-height: 1.2em;
padding: 8px;
border-radius: 4px;
/*设置高度*/
overflow: hidden;
overflow-y: auto;
word-wrap: break-word;
overflow-wrap: break-word;
word-break: break-all;
/*设置宽度*/
max-width: 100%;
}
.status-success {
@ -102,8 +110,6 @@
background: #e3f2fd;
color: var(--primary-color);
}
</style>
</head>
<body>
@ -144,7 +150,7 @@
const {createApp, ref, onMounted, computed} = Vue;
const API_CONFIG = {
ENDPOINT: 'http://10.23.0.209:8778/convert',
ENDPOINT: 'http://localhost:8778/convert',
DEFAULT_HEADERS: {
'Content-Type': 'application/x-www-form-urlencoded'
},
@ -182,13 +188,15 @@
});
const statusClass = computed(() => {
// 控制台打印
console.log(`1Status: ${statusType.value} - ${statusMessage.value}`);
return statusType.value ? `status-${statusType.value}` : '';
});
const setStatus = (message, type = 'info', timeout = 3000) => {
const setStatus = (message, type = 'info', timeout = 10000) => {
statusMessage.value = message;
statusType.value = type;
if (timeout) {
setTimeout(() => {
statusMessage.value = '';
@ -307,4 +315,4 @@
}).mount('#app');
</script>
</body>
</html>
</html>