配置 API Key 环境变量,完成 FastAPI 基础配置
This commit is contained in:
19
backend/app/main.py
Normal file
19
backend/app/main.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from fastapi import FastAPI
|
||||
from config import settings
|
||||
|
||||
app = FastAPI(
|
||||
title=settings.APP_NAME,
|
||||
openapi_url=f"{settings.API_V1_STR}/openapi.json"
|
||||
)
|
||||
|
||||
@app.get("/")
|
||||
async def root():
|
||||
return {
|
||||
"message": f"Welcome to {settings.APP_NAME}",
|
||||
"status": "online",
|
||||
"debug_mode": settings.DEBUG
|
||||
}
|
||||
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
uvicorn.run("main:app", host="127.0.0.1", port=8000, reload=True)
|
||||
Reference in New Issue
Block a user