|
6 | 6 | import pydantic |
7 | 7 | import sentry_sdk |
8 | 8 | import uvicorn |
9 | | -from fastapi import FastAPI, Request, Response, openapi |
| 9 | +from fastapi import FastAPI, Request, Response |
10 | 10 | from fastapi.middleware.cors import CORSMiddleware |
11 | 11 | from fastapi.middleware.gzip import GZipMiddleware |
12 | 12 | from fastapi.responses import JSONResponse |
13 | | -from fastapi.staticfiles import StaticFiles |
14 | 13 | from scout_apm.async_.starlette import ScoutMiddleware |
15 | 14 | from sentry_sdk.integrations.asgi import SentryAsgiMiddleware |
16 | 15 |
|
|
35 | 34 | "API for tracking the global coronavirus (COVID-19, SARS-CoV-2) outbreak." |
36 | 35 | " Project page: https://github.com/ExpDev07/coronavirus-tracker-api." |
37 | 36 | ), |
38 | | - version="2.0.3", |
39 | | - docs_url=None, |
40 | | - redoc_url=None, |
| 37 | + version="2.0.4", |
| 38 | + docs_url="/", |
| 39 | + redoc_url="/docs", |
41 | 40 | on_startup=[setup_client_session], |
42 | 41 | on_shutdown=[teardown_client_session], |
43 | 42 | ) |
|
60 | 59 |
|
61 | 60 | # Enable CORS. |
62 | 61 | APP.add_middleware( |
63 | | - CORSMiddleware, allow_credentials=True, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"], |
| 62 | + CORSMiddleware, |
| 63 | + allow_credentials=True, |
| 64 | + allow_origins=["*"], |
| 65 | + allow_methods=["*"], |
| 66 | + allow_headers=["*"], |
64 | 67 | ) |
65 | 68 | APP.add_middleware(GZipMiddleware, minimum_size=1000) |
66 | 69 |
|
@@ -109,31 +112,6 @@ async def handle_validation_error( |
109 | 112 | # Include routers. |
110 | 113 | APP.include_router(V1, prefix="", tags=["v1"]) |
111 | 114 | APP.include_router(V2, prefix="/v2", tags=["v2"]) |
112 | | -APP.mount("/static", StaticFiles(directory="static"), name="static") |
113 | | - |
114 | | -# ############## |
115 | | -# Swagger/Redocs |
116 | | -# ############## |
117 | | - |
118 | | - |
119 | | -@APP.get("/", include_in_schema=False) |
120 | | -async def custom_swagger_ui_html(): |
121 | | - """Serve Swagger UI.""" |
122 | | - return openapi.docs.get_swagger_ui_html( |
123 | | - openapi_url=APP.openapi_url, |
124 | | - title=f"{APP.title} - Swagger UI", |
125 | | - oauth2_redirect_url=APP.swagger_ui_oauth2_redirect_url, |
126 | | - swagger_js_url="/static/swagger-ui-bundle.js", |
127 | | - swagger_css_url="/static/swagger-ui.css", |
128 | | - ) |
129 | | - |
130 | | - |
131 | | -@APP.get("/docs", include_in_schema=False) |
132 | | -async def redoc_html(): |
133 | | - """Serve ReDoc UI.""" |
134 | | - return openapi.docs.get_redoc_html( |
135 | | - openapi_url=APP.openapi_url, title=f"{APP.title} - ReDoc", redoc_js_url="/static/redoc.standalone.js", |
136 | | - ) |
137 | 115 |
|
138 | 116 |
|
139 | 117 | # Running of app. |
|
0 commit comments