-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
40 lines (31 loc) · 969 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
33
34
35
36
37
38
39
40
"""FastAPI server."""
import textwrap
from fastapi import FastAPI, status
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import ORJSONResponse
from src.core.config.api import APIConfig
rosa = FastAPI(
title=APIConfig.TITLE,
version=APIConfig.VERSION,
summary=APIConfig.SUMMARY,
description=textwrap.dedent(APIConfig.DESCRIPTION),
default_response_class=ORJSONResponse,
root_path=f"/{APIConfig.VERSION}",
redirect_slashes=True,
)
rosa.add_middleware(
middleware_class=CORSMiddleware,
allow_origins=APIConfig.CORS_ORIGINS,
)
@rosa.get(
"/",
status_code=status.HTTP_200_OK,
response_class=ORJSONResponse,
)
def home() -> ORJSONResponse:
"""Home route."""
return ORJSONResponse(content={"content": "successful response."})
from src.cms.api import article, author, category
rosa.include_router(router=article)
rosa.include_router(router=author)
rosa.include_router(router=category)