Adding a swtch for local environments.
This commit is contained in:
parent
9053be8fcb
commit
9dc1f99b97
1 changed files with 7 additions and 4 deletions
11
app/main.py
11
app/main.py
|
|
@ -1,8 +1,12 @@
|
||||||
|
import os
|
||||||
|
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from fastapi.responses import RedirectResponse
|
from fastapi.responses import RedirectResponse
|
||||||
from scalar_fastapi import get_scalar_api_reference
|
from scalar_fastapi import get_scalar_api_reference
|
||||||
from app.routes import discovery, reviews, stats
|
from app.routes import discovery, reviews, stats
|
||||||
|
|
||||||
|
ROOT_PATH = os.environ.get("ROOT_PATH", "")
|
||||||
|
|
||||||
DESCRIPTION = """
|
DESCRIPTION = """
|
||||||
Hi, this is a read-only API exposing 20+ years of my personal media reviews of movies, books,
|
Hi, this is a read-only API exposing 20+ years of my personal media reviews of movies, books,
|
||||||
and television since 2001.
|
and television since 2001.
|
||||||
|
|
@ -55,11 +59,10 @@ app = FastAPI(
|
||||||
redoc_url=None,
|
redoc_url=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
@app.get("/docs", include_in_schema=False)
|
@app.get("/ref", include_in_schema=False)
|
||||||
async def scalar_docs():
|
async def scalar_docs():
|
||||||
return get_scalar_api_reference(
|
return get_scalar_api_reference(
|
||||||
# openapi_url=f"{app.root_path}{app.openapi_url}",
|
openapi_url=f"{ROOT_PATH}/openapi.json",
|
||||||
openapi_url="/technical/api/openapi.json",
|
|
||||||
title=app.title,
|
title=app.title,
|
||||||
force_dark_mode_state="light",
|
force_dark_mode_state="light",
|
||||||
hide_dark_mode_toggle=True,
|
hide_dark_mode_toggle=True,
|
||||||
|
|
@ -74,7 +77,7 @@ app.include_router(stats.router)
|
||||||
|
|
||||||
@app.get("/", include_in_schema=False)
|
@app.get("/", include_in_schema=False)
|
||||||
def root_redirect():
|
def root_redirect():
|
||||||
return RedirectResponse(url="/technical/api/docs")
|
return RedirectResponse(url=f"{ROOT_PATH}/ref")
|
||||||
|
|
||||||
@app.get("/health", tags=["System"])
|
@app.get("/health", tags=["System"])
|
||||||
def health_check():
|
def health_check():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue