add fastapi init
This commit is contained in:
26
chat/main.py
Normal file
26
chat/main.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from fastapi import FastAPI
|
||||
from api.v1 import ai_chat
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
origins = [
|
||||
"http://localhost",
|
||||
"http://localhost:8010",
|
||||
]
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=origins,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
# 注册路由
|
||||
app.include_router(ai_chat.router, prefix="/chat/api/v1", tags=["chat"])
|
||||
|
||||
# 健康检查
|
||||
@app.get("/ping")
|
||||
def ping():
|
||||
return {"msg": "pong"}
|
||||
Reference in New Issue
Block a user