-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
45 lines (37 loc) · 1.21 KB
/
main.py
File metadata and controls
45 lines (37 loc) · 1.21 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
36
37
38
39
40
41
42
43
44
45
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from src.core.config import Settings
import uvicorn
settings = Settings()
app = FastAPI()
# CORS 미들웨어 설정
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # 프로덕션에서는 구체적인 도메인으로 제한하는 것이 좋습니다
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# from src.v1.router import routers as v1_routers
from src.v2.router import routers as v2_routers
# for router in v1_routers:
# app.include_router(router)
for router in v2_routers:
app.include_router(router)
@app.get("/")
async def root():
return {
"name": settings.TITLE,
"version": settings.VERSION,
"status": settings.STATUS,
"api_title": settings.API_TITLE,
"api_version": settings.API_VERSION,
"now": settings.now
}
@app.get("/health")
def health_check():
return {"status": "ok"}
if __name__ == "__main__":
# 0.0.0.0으로 설정하면 모든 네트워크 인터페이스에서 접근 가능합니다.
# 포트는 8000을 사용하지만 필요시 변경 가능합니다.
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=settings.DEBUG)