Files
crawler-plugin/backend/app.py
2026-06-14 19:00:55 +08:00

41 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
卖相AI - Flask 后端
按功能拆分为蓝图:认证(auth)、主页面(main)、管理员API(admin_api)、版本(version)
"""
import os
import secrets
from datetime import timedelta
from flask import Flask
from flask_cors import CORS
from utils.db import init_db
from blueprints.auth import auth
from blueprints.main import main
from blueprints.admin_api import admin_api
from blueprints.version import version_bp
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
app = Flask(__name__, template_folder=BASE_DIR, static_folder=BASE_DIR)
CORS(app)
app.secret_key = os.environ.get('SECRET_KEY', secrets.token_hex(32))
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=7)
# 文件上传大小限制2GB数字人 ZIP 包等大文件)
app.config['MAX_CONTENT_LENGTH'] = 2 * 1024 * 1024 * 1024
# 注册蓝图
app.register_blueprint(auth)
app.register_blueprint(main)
app.register_blueprint(admin_api)
app.register_blueprint(version_bp)
def run_app(host='0.0.0.0', port=15124):
init_db()
app.run(host=host, port=port, threaded=True, use_reloader=False)
if __name__ == '__main__':
run_app()