23 lines
593 B
Python
23 lines
593 B
Python
# 文件路径: app/__init__.py
|
|
from flask import Flask
|
|
from config import Config
|
|
from app.extensions import db, migrate, cors
|
|
|
|
def create_app():
|
|
app = Flask(__name__)
|
|
app.config.from_object(Config)
|
|
|
|
# 初始化插件
|
|
db.init_app(app)
|
|
migrate.init_app(app, db)
|
|
cors.init_app(app) # 允许前端访问
|
|
|
|
# 注册蓝图 (Blueprints)
|
|
from app.api.v1.stocks import stocks_bp
|
|
app.register_blueprint(stocks_bp, url_prefix='/api/v1/stocks')
|
|
|
|
# 可以在这里打印一下路由,方便调试
|
|
print("已注册路由:")
|
|
print(app.url_map)
|
|
|
|
return app |