forked from thinkany-ai/rag-search
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
34 lines (23 loc) · 580 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from fastapi import FastAPI
from contextlib import asynccontextmanager
from components.log import init_log, log
from components.env import init_env
from handlers.rag_search import rag_router
def startup():
print("init log")
init_log()
print("init env")
init_env()
log.info("app start")
def shutdown():
log.info("app shutdown")
@asynccontextmanager
async def lifespan(app: FastAPI):
startup()
yield
shutdown()
app = FastAPI(lifespan=lifespan)
app.include_router(rag_router)
@app.get("/")
async def root():
return {"ping": "pong"}