- 新增异步图片生成处理函数,支持后台任务执行及积分退还机制 - 实现任务状态查询接口,支持前端实时获取生成进度和结果 - 优化生成逻辑:根据模型类型分流,聊天模型同步调用,图片模型异步执行 - 调整积分预扣除和退还逻辑,保障用户积分安全 - 后台线程同步图片至私有存储,提升响应性能和用户体验 - 新增 /visualizer 路由对应前端控制器页面,辅助3D构图和拍摄角度设置 - 优化前端上传逻辑,新增设置器模式时单图上传限制 - 移除项目中未使用的前端脚本与配置文件,简化代码库维护
52 lines
1.3 KiB
Python
52 lines
1.3 KiB
Python
from flask import Flask, render_template
|
|
from config import Config
|
|
from extensions import db, redis_client
|
|
from blueprints.auth import auth_bp
|
|
from blueprints.api import api_bp
|
|
from blueprints.admin import admin_bp
|
|
from blueprints.payment import payment_bp
|
|
import threading
|
|
import time
|
|
|
|
# 导入模型(必须在 db.create_all() 之前导入)
|
|
import models
|
|
|
|
def create_app():
|
|
app = Flask(__name__)
|
|
app.config.from_object(Config)
|
|
|
|
# 初始化扩展
|
|
db.init_app(app)
|
|
redis_client.init_app(app)
|
|
|
|
# 注册蓝图
|
|
app.register_blueprint(auth_bp)
|
|
app.register_blueprint(api_bp)
|
|
app.register_blueprint(admin_bp)
|
|
app.register_blueprint(payment_bp)
|
|
|
|
@app.route('/')
|
|
def index():
|
|
return render_template('index.html')
|
|
|
|
@app.route('/ocr')
|
|
def ocr():
|
|
return render_template('ocr.html')
|
|
|
|
@app.route('/visualizer')
|
|
def visualizer():
|
|
return render_template('kongzhiqi.html')
|
|
|
|
# 自动创建数据库表
|
|
with app.app_context():
|
|
print("🔧 正在检查并创建数据库表...")
|
|
db.create_all()
|
|
print("✅ 数据库表已就绪")
|
|
|
|
return app
|
|
|
|
app = create_app()
|
|
|
|
if __name__ == '__main__':
|
|
app.run(host='0.0.0.0', port=5000, debug=True)
|