Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,6 +13,8 @@ import requests
|
|
| 13 |
from flask import Flask, request, Response, jsonify, stream_with_context, render_template, redirect, session
|
| 14 |
from curl_cffi import requests as curl_requests
|
| 15 |
from werkzeug.middleware.proxy_fix import ProxyFix
|
|
|
|
|
|
|
| 16 |
|
| 17 |
|
| 18 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
@@ -1039,21 +1041,24 @@ def manager():
|
|
| 1039 |
return render_template('manager.html')
|
| 1040 |
|
| 1041 |
|
| 1042 |
-
@app.route('/manager/api/
|
| 1043 |
-
def
|
| 1044 |
-
|
| 1045 |
-
|
| 1046 |
-
|
| 1047 |
-
|
| 1048 |
-
@app.route('/manager/api/xids'))
|
| 1049 |
-
def set_xids():
|
| 1050 |
-
if request.headers.get('Authorization') != CONFIG["ADMIN"]["PASSWORD"]:
|
| 1051 |
return jsonify({"error": "Unauthorized"}), 401
|
| 1052 |
|
| 1053 |
CONFIG["XIDS"] = request.json
|
| 1054 |
logger.info(f"get XIDS: {CONFIG['XIDS']}", "Server")
|
| 1055 |
return jsonify({"success": True})
|
| 1056 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1057 |
|
| 1058 |
@app.route('/manager/api/add', methods=['POST'])
|
| 1059 |
def add_manager_token():
|
|
|
|
| 13 |
from flask import Flask, request, Response, jsonify, stream_with_context, render_template, redirect, session
|
| 14 |
from curl_cffi import requests as curl_requests
|
| 15 |
from werkzeug.middleware.proxy_fix import ProxyFix
|
| 16 |
+
import get_xid
|
| 17 |
+
import threading
|
| 18 |
|
| 19 |
|
| 20 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
| 1041 |
return render_template('manager.html')
|
| 1042 |
|
| 1043 |
|
| 1044 |
+
@app.route('/manager/api/xids',methods=['POST'])
|
| 1045 |
+
def set_xid():
|
| 1046 |
+
auth = request.headers.get('Authorization')
|
| 1047 |
+
if auth is not None:
|
| 1048 |
+
auth = auth.replace('Bearer ', '')
|
| 1049 |
+
if auth != CONFIG["ADMIN"]["PASSWORD"]:
|
|
|
|
|
|
|
|
|
|
| 1050 |
return jsonify({"error": "Unauthorized"}), 401
|
| 1051 |
|
| 1052 |
CONFIG["XIDS"] = request.json
|
| 1053 |
logger.info(f"get XIDS: {CONFIG['XIDS']}", "Server")
|
| 1054 |
return jsonify({"success": True})
|
| 1055 |
|
| 1056 |
+
@app.route('/manager/api/get')
|
| 1057 |
+
def get_manager_tokens():
|
| 1058 |
+
if not check_auth():
|
| 1059 |
+
return jsonify({"error": "Unauthorized"}), 401
|
| 1060 |
+
return jsonify(token_manager.get_token_status_map())
|
| 1061 |
+
|
| 1062 |
|
| 1063 |
@app.route('/manager/api/add', methods=['POST'])
|
| 1064 |
def add_manager_token():
|