from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from .api.routes import router

# 创建FastAPI应用
app = FastAPI(title="云计算价格计算器", description="支持多云平台的价格计算服务")

# 配置CORS
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# 包含API路由
app.include_router(router)

# 主页路由
@app.get("/")
async def root():
    return {"message": "欢迎使用云计算价格计算器API", "version": "1.0.0"}

if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000) 