Spaces:
Sleeping
Sleeping
paleDriver7
commited on
Commit
•
ae3d79e
1
Parent(s):
1fee8a1
Update backend/app.py
Browse files- backend/app.py +20 -4
backend/app.py
CHANGED
@@ -7,7 +7,7 @@ sys.path.append(os.path.dirname(__file__)) # 确保当前目录加入模块搜
|
|
7 |
|
8 |
from llama3 import LlaMa3 # 导入您的 LlaMa3 类
|
9 |
|
10 |
-
app = Flask(__name__)
|
11 |
CORS(app)
|
12 |
|
13 |
# 实例化 LlaMa3 模型
|
@@ -18,10 +18,26 @@ llama3_model = LlaMa3()
|
|
18 |
#def health_check():
|
19 |
# return "Service is running!", 200
|
20 |
|
21 |
-
|
22 |
-
def index():
|
23 |
# 返回 HTML 页面
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
@app.route('/chat', methods=['POST'])
|
27 |
def chat():
|
|
|
7 |
|
8 |
from llama3 import LlaMa3 # 导入您的 LlaMa3 类
|
9 |
|
10 |
+
app = Flask(__name__, static_folder='../frontend/dist', template_folder='../frontend/dist')
|
11 |
CORS(app)
|
12 |
|
13 |
# 实例化 LlaMa3 模型
|
|
|
18 |
#def health_check():
|
19 |
# return "Service is running!", 200
|
20 |
|
21 |
+
#@app.route('/')
|
22 |
+
#def index():
|
23 |
# 返回 HTML 页面
|
24 |
+
# return render_template('index_s.html')
|
25 |
+
|
26 |
+
#添加一个路由来处理静态资源的请求
|
27 |
+
@app.route('/<path:filename>')
|
28 |
+
def serve_static(filename):
|
29 |
+
return send_from_directory(app.static_folder, filename)
|
30 |
+
|
31 |
+
|
32 |
+
#配置默认路由
|
33 |
+
#让 Flask 将所有非静态文件请求重定向到 index.html,以支持前端的 SPA 路由:
|
34 |
+
@app.route('/')
|
35 |
+
@app.route('/<path:subpath>')
|
36 |
+
def index(subpath=None):
|
37 |
+
return send_from_directory(app.template_folder, 'index.html')
|
38 |
+
|
39 |
+
|
40 |
+
|
41 |
|
42 |
@app.route('/chat', methods=['POST'])
|
43 |
def chat():
|