26 lines
643 B
Python
26 lines
643 B
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.api.v1.api import api_router
|
|
from app.core.config import settings
|
|
|
|
app = FastAPI(
|
|
title="温度数据采集系统",
|
|
description="温度数据采集系统API接口",
|
|
version="1.0.0"
|
|
)
|
|
|
|
# 配置CORS
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"], # 在生产环境中应该设置具体的域名
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# 注册路由
|
|
app.include_router(api_router)
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {"message": "温度数据采集系统API服务正在运行"} |