40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
from flask import Flask
|
|
from flask_cors import CORS
|
|
from routes.langgraph_routes import bp as langgraph_bp
|
|
from config.web_config import WEB_CONFIG
|
|
|
|
def create_app():
|
|
"""应用工厂函数"""
|
|
app = Flask(__name__)
|
|
|
|
# 应用配置
|
|
app.config['SECRET_KEY'] = WEB_CONFIG['secret_key']
|
|
app.config['SESSION_TYPE'] = WEB_CONFIG['session_type']
|
|
app.config['SESSION_PERMANENT'] = WEB_CONFIG['session_permanent']
|
|
app.config['SESSION_USE_SIGNER'] = WEB_CONFIG['session_use_signer']
|
|
app.config['SESSION_KEY_PREFIX'] = WEB_CONFIG['session_key_prefix']
|
|
app.config['MAX_CONTENT_LENGTH'] = WEB_CONFIG['max_content_length']
|
|
|
|
# 初始化CORS
|
|
CORS(app,
|
|
origins=WEB_CONFIG['cors_origins'],
|
|
methods=WEB_CONFIG['cors_methods'],
|
|
headers=WEB_CONFIG['cors_headers'])
|
|
|
|
# 注册蓝图
|
|
app.register_blueprint(langgraph_bp, url_prefix=WEB_CONFIG['api_prefix'])
|
|
|
|
@app.route('/health')
|
|
def health_check():
|
|
"""健康检查端点"""
|
|
return {'status': 'healthy', 'message': 'LangGraph Web Service is running'}
|
|
|
|
return app
|
|
|
|
if __name__ == '__main__':
|
|
app = create_app()
|
|
app.run(
|
|
host=WEB_CONFIG['host'],
|
|
port=WEB_CONFIG['port'],
|
|
debug=WEB_CONFIG['debug']
|
|
) |