Initial commit
This commit is contained in:
38
backend/app/main.py
Normal file
38
backend/app/main.py
Normal file
@ -0,0 +1,38 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from app.api.routes import router
|
||||
from app.core.bootstrap import bootstrap_data
|
||||
from app.services.sync_scheduler import sync_scheduler
|
||||
|
||||
|
||||
def create_app() -> FastAPI:
|
||||
app = FastAPI(
|
||||
title="Southbound Capital Monitor",
|
||||
version="0.1.0",
|
||||
description="南向资金监控平台 API",
|
||||
)
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"],
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
bootstrap_data()
|
||||
|
||||
@app.on_event("startup")
|
||||
def startup_sync_scheduler() -> None:
|
||||
sync_scheduler.start()
|
||||
|
||||
@app.on_event("shutdown")
|
||||
def shutdown_sync_scheduler() -> None:
|
||||
sync_scheduler.stop()
|
||||
|
||||
app.include_router(router, prefix="/api")
|
||||
return app
|
||||
|
||||
|
||||
app = create_app()
|
||||
Reference in New Issue
Block a user