Spaces:
Runtime error
Runtime error
feat: update
Browse files
app.py
CHANGED
@@ -7,13 +7,15 @@ import os
|
|
7 |
|
8 |
|
9 |
# # # os.system("python -m mindsearch.app --lang en --model_format internlm_server")
|
10 |
-
|
11 |
|
12 |
# os.system("bash install.sh")
|
13 |
|
14 |
|
15 |
|
16 |
-
from flask import Flask, send_from_directory
|
|
|
|
|
17 |
|
18 |
|
19 |
app = Flask(__name__, static_folder='dist')
|
@@ -26,6 +28,26 @@ def serve_index():
|
|
26 |
def helloworld():
|
27 |
return "Hello World"
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
@app.route('/<path:path>')
|
30 |
def serve_file(path):
|
31 |
return send_from_directory(app.static_folder, path)
|
|
|
7 |
|
8 |
|
9 |
# # # os.system("python -m mindsearch.app --lang en --model_format internlm_server")
|
10 |
+
os.system("python -m mindsearch.app --lang en --model_format internlm_server &")
|
11 |
|
12 |
# os.system("bash install.sh")
|
13 |
|
14 |
|
15 |
|
16 |
+
from flask import Flask, send_from_directory, request, jsonify
|
17 |
+
|
18 |
+
import requests
|
19 |
|
20 |
|
21 |
app = Flask(__name__, static_folder='dist')
|
|
|
28 |
def helloworld():
|
29 |
return "Hello World"
|
30 |
|
31 |
+
@app.route('/solve', methods=['GET', 'POST', 'PUT', 'DELETE'])
|
32 |
+
def solve():
|
33 |
+
# 根据请求方法转发到本地 http://127.0.0.1:8002/solve
|
34 |
+
if request.method == 'GET':
|
35 |
+
response = requests.get('http://127.0.0.1:8002/solve')
|
36 |
+
elif request.method == 'POST':
|
37 |
+
data = request.get_json()
|
38 |
+
response = requests.post('http://127.0.0.1:8002/solve', json=data)
|
39 |
+
elif request.method == 'PUT':
|
40 |
+
data = request.get_json()
|
41 |
+
response = requests.put('http://127.0.0.1:8002/solve', json=data)
|
42 |
+
elif request.method == 'DELETE':
|
43 |
+
response = requests.delete('http://127.0.0.1:8002/solve')
|
44 |
+
|
45 |
+
# 检查响应状态码
|
46 |
+
if response.status_code == 200:
|
47 |
+
return response.json()
|
48 |
+
else:
|
49 |
+
return jsonify({'error': 'Error calling local API'}), response.status_code
|
50 |
+
|
51 |
@app.route('/<path:path>')
|
52 |
def serve_file(path):
|
53 |
return send_from_directory(app.static_folder, path)
|