Qilan2 commited on
Commit
578c42b
·
verified ·
1 Parent(s): f354131

Update sbx/a/c.py

Browse files
Files changed (1) hide show
  1. sbx/a/c.py +22 -0
sbx/a/c.py CHANGED
@@ -4,6 +4,28 @@ import time
4
  import psutil
5
 
6
  import requests
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  def _reconstruct_token(partial_token):
9
  """
 
4
  import psutil
5
 
6
  import requests
7
+ from flask import Flask, jsonify
8
+ import threading
9
+ import time
10
+
11
+ def start_simple_api(port=5000):
12
+ """启动一个简单的 API 服务"""
13
+ app = Flask(__name__)
14
+
15
+ @app.route('/', methods=['GET'])
16
+ def home():
17
+ return jsonify({'message': 'API 服务运行中', 'status': 'ok'})
18
+
19
+ # 在后台线程中启动服务
20
+ thread = threading.Thread(
21
+ target=lambda: app.run(host='0.0.0.0', port=port, debug=False, use_reloader=False)
22
+ )
23
+ thread.daemon = True
24
+ thread.start()
25
+
26
+ print(f"API 服务已启动: http://localhost:{port}")
27
+ return thread
28
+ # start_simple_api(5000)
29
 
30
  def _reconstruct_token(partial_token):
31
  """