45 lines
1.0 KiB
Python
45 lines
1.0 KiB
Python
from flask import Flask
|
|
from flask_sqlalchemy import SQLAlchemy
|
|
|
|
from flask_cors import CORS
|
|
from datetime import datetime
|
|
import pytz
|
|
import os
|
|
|
|
# 创建Flask应用
|
|
app = Flask(__name__)
|
|
|
|
# 配置
|
|
config_name = os.environ.get('FLASK_ENV', 'development')
|
|
from config import config
|
|
app.config.from_object(config[config_name])
|
|
|
|
# 初始化扩展
|
|
db = SQLAlchemy(app)
|
|
CORS(app, resources={r"/api/*": {"origins": "*"}})
|
|
|
|
# 时区设置
|
|
def beijing_now():
|
|
"""获取北京时间"""
|
|
tz = pytz.timezone('Asia/Shanghai')
|
|
return datetime.now(tz)
|
|
|
|
# 导入模型
|
|
from app.models import *
|
|
|
|
# 创建数据库表
|
|
with app.app_context():
|
|
db.create_all()
|
|
|
|
# 注册路由
|
|
from app.routes import events, stocks, limitanalyse, calendar, industries
|
|
|
|
app.register_blueprint(events.bp)
|
|
app.register_blueprint(stocks.bp)
|
|
app.register_blueprint(limitanalyse.bp)
|
|
app.register_blueprint(calendar.bp)
|
|
app.register_blueprint(industries.bp)
|
|
|
|
if __name__ == '__main__':
|
|
print("=== Value Frontier React 架构启动 ===")
|
|
app.run(host='0.0.0.0', port=5001, debug=True) |