-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
35 lines (26 loc) · 1.05 KB
/
Copy pathmain.py
File metadata and controls
35 lines (26 loc) · 1.05 KB
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
35
from fastapi import FastAPI, Depends, APIRouter, Request
#import models
#from database import engine
from routers import chat_v2 as chat
from starlette.staticfiles import StaticFiles
from fastapi.responses import HTMLResponse
from fastapi.templating import Jinja2Templates
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # 모든 출처 허용
allow_credentials=True,
allow_methods=["*"], # 모든 메서드 허용
allow_headers=["*"], # 모든 헤더 허용
)
#models.Base.metadata.create_all(bind=engine)
templates = Jinja2Templates(directory="templates")
app.mount("/static", StaticFiles(directory="static"), name="static")
@app.get("/",response_class=HTMLResponse)
async def render_homepage(request: Request):
return templates.TemplateResponse('home.html',{"request":request})
@app.get("/test",response_class=HTMLResponse)
async def test(request: Request):
return templates.TemplateResponse('test.html',{"request":request})
app.include_router(chat.router)