Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ import requests
|
|
7 |
import os
|
8 |
|
9 |
app = Flask(__name__)
|
10 |
-
CORS(app, origins=[
|
11 |
"https://x-raremeta.com",
|
12 |
"https://cybercity.top",
|
13 |
"https://play-1.x-raremeta.com",
|
@@ -51,7 +51,12 @@ def get_access_token(jwt_token):
|
|
51 |
response = requests.post(url, json=data, headers=headers)
|
52 |
return response.json()
|
53 |
|
54 |
-
#
|
|
|
|
|
|
|
|
|
|
|
55 |
@app.route('/get_token', methods=['GET'])
|
56 |
def get_token_from_flask():
|
57 |
auth_header = request.headers.get('Authorization')
|
@@ -75,7 +80,7 @@ def get_token_from_flask():
|
|
75 |
except Exception as e:
|
76 |
return jsonify({"error": str(e)}), 500
|
77 |
|
78 |
-
#
|
79 |
-
|
80 |
if __name__ == '__main__':
|
81 |
-
app.run(host="0.0.0.0", port=
|
|
|
7 |
import os
|
8 |
|
9 |
app = Flask(__name__)
|
10 |
+
CORS(app, origins=["https://catptain-coze-api-01.hf.space"] + [
|
11 |
"https://x-raremeta.com",
|
12 |
"https://cybercity.top",
|
13 |
"https://play-1.x-raremeta.com",
|
|
|
51 |
response = requests.post(url, json=data, headers=headers)
|
52 |
return response.json()
|
53 |
|
54 |
+
# 添加根路由,帮助Hugging Face识别应用已经就绪
|
55 |
+
@app.route('/', methods=['GET'])
|
56 |
+
def index():
|
57 |
+
return jsonify({"status": "Service is running", "endpoints": ["/get_token"]}), 200
|
58 |
+
|
59 |
+
# 正确的token获取路由
|
60 |
@app.route('/get_token', methods=['GET'])
|
61 |
def get_token_from_flask():
|
62 |
auth_header = request.headers.get('Authorization')
|
|
|
80 |
except Exception as e:
|
81 |
return jsonify({"error": str(e)}), 500
|
82 |
|
83 |
+
# 使用环境变量设置端口
|
84 |
+
port = int(os.environ.get("PORT", 7860))
|
85 |
if __name__ == '__main__':
|
86 |
+
app.run(host="0.0.0.0", port=port)
|