29 lines
858 B
Python
29 lines
858 B
Python
# run.py(仅用于开发测试)
|
|
import os
|
|
|
|
from flask import current_app, send_from_directory
|
|
from app import create_app
|
|
|
|
|
|
# 开发环境配置(启用 DEBUG、自动重载等)
|
|
app = create_app()
|
|
|
|
@app.route('/uploads/<path:filename>')
|
|
def serve_uploads(filename):
|
|
"""静态资源路由:允许访问/uploads下的所有文件"""
|
|
return send_from_directory(current_app.config['UPLOAD_FOLDER'], filename)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
# Flask 自带开发服务器:支持自动重载、调试日志
|
|
app.run(
|
|
host="0.0.0.0", # 允许外部访问
|
|
port=5221, # 端口(与 Gunicorn 配置一致,便于测试)
|
|
debug=True, # 开发模式:自动重载、显示错误详情
|
|
use_reloader=True, # 代码修改后自动重启
|
|
)
|
|
|
|
# app.run(host="0.0.0.0", port=5221, debug=False)
|
|
|
|
|