sstar_l0l3clip_sync/python_flask_http_server/server.py

25 lines
755 B
Python
Raw Normal View History

from flask import Flask, send_from_directory, request,jsonify
import sys
app = Flask(__name__)
@app.route('/SSWeb/rd/copy_paste.jsp')
def copy_paste():
return send_from_directory('templates', 'copy_paste.html')
@app.route('/SSWeb/rd/copy_paste.jsp', methods=['POST'])
def recive_msg():
# 获取查询参数
send_param = request.args.get('send')
if not send_param:
return jsonify({
"zz": "must send query param"
})
# 获取 JSON 数据
data = request.get_data().decode()
print(f"msg is [{data}]\n")
return send_from_directory('templates', 'copy_paste.html')
if __name__ == '__main__':
sys.stdout.reconfigure(encoding='utf-8')
app.run(host='0.0.0.0', port=5000)