b0503baac5
2. callcenter 프로젝트 제작중
34 lines
963 B
Python
34 lines
963 B
Python
from fastapi import FastAPI
|
|
from starlette.staticfiles import StaticFiles
|
|
from contextlib import asynccontextmanager
|
|
|
|
from backend.repository.db_init import Base, SessionLocal, engine
|
|
from backend.routers.call_router import router as call_router
|
|
from backend.repository.seed import seed_customers
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
print("서버 시작")
|
|
|
|
# Base 에 등록된 모든 모델에 테이블 자동 생성
|
|
Base.metadata.create_all(bind=engine)
|
|
print("[DB] 테이블 생성 완료 (또는 이미 존재)")
|
|
|
|
db = SessionLocal()
|
|
try:
|
|
# 기본 user 데이터 삽입
|
|
seed_customers(db)
|
|
finally:
|
|
db.close()
|
|
|
|
yield
|
|
print("서버 종료")
|
|
|
|
# app = FastAPI()
|
|
app = FastAPI(title="상담 LLM", version="1.0", lifespan=lifespan)
|
|
|
|
# static 폴더 지정
|
|
app.mount("/static", StaticFiles(directory="backend/static"), name="static")
|
|
|
|
# 라우터 등록
|
|
app.include_router(call_router) |