Skip to content

Commit

Permalink
[ENH] Changed the favicon to neurobagel logo (#20)
Browse files Browse the repository at this point in the history
* Changed the favicon to neurobagel logo

* Updated favicon_url
  • Loading branch information
rmanaem authored Nov 15, 2023
1 parent 32a990b commit 92d2190
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
import uvicorn
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import ORJSONResponse
from fastapi.openapi.docs import get_redoc_html, get_swagger_ui_html
from fastapi.responses import ORJSONResponse, RedirectResponse

from .api.routers import attributes, query

app = FastAPI(default_response_class=ORJSONResponse)
app = FastAPI(
default_response_class=ORJSONResponse, docs_url=None, redoc_url=None
)
favicon_url = "https://raw.githubusercontent.com/neurobagel/documentation/main/docs/imgs/logo/neurobagel_favicon.png"

app.add_middleware(
CORSMiddleware,
Expand All @@ -18,6 +22,38 @@
)


@app.get("/favicon.ico", include_in_schema=False)
async def favicon():
"""
Overrides the default favicon with a custom one.
"""
return RedirectResponse(url=favicon_url)


@app.get("/docs", include_in_schema=False)
def overridden_swagger():
"""
Overrides the Swagger UI HTML for the "/docs" endpoint.
"""
return get_swagger_ui_html(
openapi_url="/openapi.json",
title="Neurobagel Federation API",
swagger_favicon_url=favicon_url,
)


@app.get("/redoc", include_in_schema=False)
def overridden_redoc():
"""
Overrides the Redoc HTML for the "/redoc" endpoint.
"""
return get_redoc_html(
openapi_url="/openapi.json",
title="Neurobagel Federation API",
redoc_favicon_url=favicon_url,
)


app.include_router(query.router)
app.include_router(attributes.router)

Expand Down

0 comments on commit 92d2190

Please sign in to comment.