forked from Yezz123-Archive/ChefAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
32 lines (24 loc) · 830 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
from fastapi import FastAPI
from starlette.middleware.cors import CORSMiddleware
from api.api import api_router
from core.config import settings
app = FastAPI(
title=settings.PROJECT_NAME, openapi_url=f"{settings.API_V1_STR}/openapi.json"
)
# Set all CORS enabled origins
# TODO: Add origins in settings.BACKEND_CORS_ORIGINS
if settings.BACKEND_CORS_ORIGINS:
app.add_middleware(
CORSMiddleware,
allow_origins=[str(origin)
for origin in settings.BACKEND_CORS_ORIGINS],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Include and register api routers/endpoints
app.include_router(api_router, prefix=settings.API_V1_STR)
# Health url
@app.get("/ping", description="ChefAPI recipes,Yummy")
def pong():
return {"msg": "pong"}