1
1
forked from wangqifan/calc
calc/backend/app/main.py

27 lines
670 B
Python
Raw Permalink Normal View History

2025-04-02 16:57:05 +08:00
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)