success
This commit is contained in:
parent
f434b83090
commit
a8a0beb277
2
app.py
2
app.py
@ -60,5 +60,5 @@ def internal_server_error(e):
|
||||
return render_template('error.html', error='服务器内部错误'), 500
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True, host='0.0.0.0', port=5010)
|
||||
app.run(debug=True, host='0.0.0.0', port=5009)
|
||||
|
||||
|
@ -3,16 +3,18 @@ Flask==2.0.1
|
||||
Werkzeug==2.0.1
|
||||
mysql-connector-python==8.0.27
|
||||
bcrypt==3.2.0
|
||||
itsdangerous==2.2.0
|
||||
Jinja2==3.1.6
|
||||
MarkupSafe==3.0.2
|
||||
|
||||
# 模型和数据处理 - 系统适配版本
|
||||
tensorflow-macos>=2.9.0; platform_system=="Darwin" and platform_machine=="arm64" # Mac M1/M2
|
||||
tensorflow-cpu>=2.9.0; platform_system!="Darwin" or platform_machine!="arm64" # 其他系统
|
||||
# tensorflow-gpu>=2.9.0 # 如果有GPU,可以取消此注释
|
||||
|
||||
# 基础数据处理
|
||||
numpy>=1.20.0
|
||||
# 模型和数据处理
|
||||
tensorflow==2.19.0 # 使用当前已安装的版本
|
||||
tensorflow-io-gcs-filesystem==0.37.1
|
||||
numpy==2.0.2
|
||||
jieba==0.42.1
|
||||
scikit-learn>=1.0.0
|
||||
scikit-learn==1.6.1
|
||||
scipy==1.13.1
|
||||
h5py==3.13.0
|
||||
|
||||
# 文件处理
|
||||
rarfile==4.0
|
||||
@ -20,9 +22,31 @@ python-dateutil==2.8.2
|
||||
|
||||
# 邮件服务
|
||||
Flask-Mail==0.9.1
|
||||
blinker==1.9.0
|
||||
|
||||
# 工具类
|
||||
python-dotenv==0.20.0
|
||||
requests==2.32.3
|
||||
six==1.17.0
|
||||
|
||||
# 生产部署
|
||||
gunicorn==20.1.0
|
||||
|
||||
# TensorFlow依赖
|
||||
absl-py==2.1.0
|
||||
astunparse==1.6.3
|
||||
flatbuffers==25.2.10
|
||||
gast==0.6.0
|
||||
google-pasta==0.2.0
|
||||
grpcio==1.71.0
|
||||
keras==3.9.0
|
||||
markdown==3.7
|
||||
ml_dtypes==0.5.1
|
||||
opt_einsum==3.4.0
|
||||
packaging==24.2
|
||||
protobuf==5.29.3
|
||||
tensorboard==2.19.0
|
||||
tensorboard-data-server==0.7.2
|
||||
termcolor==2.5.0
|
||||
typing_extensions==4.12.2
|
||||
wrapt==1.17.2
|
@ -2,10 +2,18 @@ from flask import Blueprint
|
||||
|
||||
# 导入各个路由模块
|
||||
from routes.auth import auth
|
||||
# 后续会添加其他路由模块
|
||||
from routes.classify import classify_bp
|
||||
|
||||
# 创建注册蓝图的函数
|
||||
def register_blueprints(app):
|
||||
"""在Flask应用中注册所有蓝图"""
|
||||
# 认证相关路由,使用/auth前缀
|
||||
app.register_blueprint(auth, url_prefix='/auth')
|
||||
|
||||
# 分类相关路由,使用/api/classify前缀
|
||||
app.register_blueprint(classify_bp) # classify_bp已经在定义时设置了url_prefix='/api/classify'
|
||||
|
||||
# 打印所有注册的路由(调试用,可选)
|
||||
print("已注册的路由:")
|
||||
for rule in app.url_map.iter_rules():
|
||||
print(f"{rule.endpoint}: {rule.rule}")
|
19
utils/db.py
19
utils/db.py
@ -1,6 +1,7 @@
|
||||
import mysql.connector
|
||||
from mysql.connector import Error
|
||||
import config
|
||||
from flask import g
|
||||
|
||||
def get_db_connection():
|
||||
"""创建数据库连接"""
|
||||
@ -20,3 +21,21 @@ def close_connection(conn):
|
||||
"""关闭数据库连接"""
|
||||
if conn:
|
||||
conn.close()
|
||||
|
||||
# 添加与routes/classify.py兼容的函数名称
|
||||
def get_db():
|
||||
"""获取数据库连接 (与classify.py兼容)"""
|
||||
if 'db' not in g:
|
||||
g.db = get_db_connection()
|
||||
return g.db
|
||||
|
||||
def close_db(e=None):
|
||||
"""关闭数据库连接 (与classify.py兼容)"""
|
||||
db = g.pop('db', None)
|
||||
if db:
|
||||
close_connection(db)
|
||||
|
||||
def init_app(app):
|
||||
"""在Flask应用中注册数据库清理函数"""
|
||||
app.teardown_appcontext(close_db)
|
||||
|
Loading…
x
Reference in New Issue
Block a user