Files

41 lines
1.1 KiB
Python
Raw Permalink Normal View History

from flask import Flask, jsonify
from flask_cors import CORS
from dotenv import load_dotenv
import os
load_dotenv()
def create_app():
app = Flask(__name__)
# Session 配置
app.secret_key = os.getenv('FLASK_SECRET_KEY', 'military-tech-voice-secret-2026')
app.config['SESSION_COOKIE_HTTPONLY'] = True
app.config['SESSION_COOKIE_SAMESITE'] = 'Lax'
app.config['PERMANENT_SESSION_LIFETIME'] = 86400 * 7 # 7天免重登
CORS(app, resources={r"/api/*": {"origins": "*"}}, supports_credentials=True)
# 初始化数据库
from app.db import init_db
init_db()
# 注册蓝图
from app.routes.tts_synthesize import bp as synthesize_bp
from app.routes.auth import bp as auth_bp
from app.routes.admin import bp as admin_bp
app.register_blueprint(synthesize_bp)
app.register_blueprint(auth_bp)
app.register_blueprint(admin_bp)
@app.route('/api/health')
def health():
return jsonify({'status': 'ok', 'service': '军事科技AI配音系统'})
return app
if __name__ == '__main__':
create_app().run(host='0.0.0.0', port=5000, debug=True)