Initial commit
This commit is contained in:
32
backend/app/main.py
Normal file
32
backend/app/main.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import logging
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from app.api.v1.endpoints import model
|
||||
|
||||
# Configure logging
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
@app.middleware("http")
|
||||
async def log_requests(request: Request, call_next):
|
||||
logger.info(f"Incoming request: {request.method} {request.url.path}")
|
||||
response = await call_next(request)
|
||||
return response
|
||||
|
||||
# CORS 미들웨어 추가
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"], # 모든 출처 허용
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"], # 모든 HTTP 메소드 허용
|
||||
allow_headers=["*"], # 모든 헤더 허용
|
||||
)
|
||||
|
||||
app.include_router(model.router, prefix="/api/v1")
|
||||
|
||||
|
||||
@app.get("/")
|
||||
def read_root():
|
||||
return {"Hello": "World"}
|
||||
Reference in New Issue
Block a user