1 from flask import Blueprint, jsonify
2 from functools import wraps
3 from flask import request
6 tele = Blueprint('tele', __name__)
21 "IP": "52.82.123.129",
30 def login_required(func):
32 def decorator(*args, **kwargs):
33 session_id = request.form.get('token')
35 session_id = request.args.get('token')
36 if session_id not in LOGINED_UUID:
37 return jsonify({"code": 400, "msg": "no user", "data": ""})
39 return func(*args, **kwargs)
44 @tele.route('/login', methods=["POST"])
46 password = request.form.get('password')
47 if password != PASSWORD:
48 return jsonify({"code": 400, "msg": "password error", "data": ""})
50 LOGINED_UUID.append(session_id)
51 response = jsonify({"code": 200, "msg": "", "data": ""})
52 response.set_cookie("tele", str(session_id), max_age=86400)
57 @tele.route('/logout', methods=["POST"])
60 response = jsonify({"code": 200, "msg": "", "data": ""})
61 response.delete_cookie("tele")
65 @tele.route('/get-all-node', methods=["GET"])
68 return jsonify({"code": 200, "msg": "", "data": NODE_LIST})
71 @tele.route('/set-node-permission', methods=["POST"])
73 def set_node_permission():
74 ip = request.form.get('ip')
75 level = request.form.get('level')
79 return jsonify({"code": 200, "msg": "", "data": ""})
80 return jsonify({"code": 400, "msg": "no ip", "data": ""})
83 @tele.route('/set-connect', methods=["POST"])
86 ip = request.form.get('ip')
87 is_connect = request.form.get('is_connect')
90 i["is_connect"] = is_connect
91 return jsonify({"code": 200, "msg": "", "data": ""})
92 return jsonify({"code": 400, "msg": "no ip", "data": ""})