34 lines
938 B
Python
34 lines
938 B
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.core.config import settings
|
|
from app.api.v1.lottery import router as lottery_router
|
|
from app.api.endpoints.analysis import router as analysis_router
|
|
from app.core.database import Base, engine
|
|
|
|
# 创建数据库表
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
app = FastAPI(
|
|
title=settings.PROJECT_NAME,
|
|
openapi_url=f"{settings.API_V1_STR}/openapi.json"
|
|
)
|
|
|
|
# 配置CORS
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"], # 允许所有来源
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# 注册路由
|
|
app.include_router(
|
|
lottery_router, prefix=f"{settings.API_V1_STR}/lottery", tags=["lottery"])
|
|
app.include_router(
|
|
analysis_router, prefix=f"{settings.API_V1_STR}/analysis", tags=["analysis"])
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
uvicorn.run(app, host="0.0.0.0", port=8000)
|