Skip to content

Commit 57571ae

Browse files
committed
Added docs favicon
1 parent 8b74ce5 commit 57571ae

4 files changed

Lines changed: 20 additions & 3 deletions

File tree

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,5 @@ install-name = "api"
4949
sources = ["src/api"]
5050

5151
[tool.hatch.build.targets.zipped-directory.force-include]
52-
".env" = "/.env"
52+
".env" = "/.env"
53+
"static" = "/static"

src/api/favicon.ico

-15 KB
Binary file not shown.

src/api/main.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
from beanie import init_beanie
1313
from fastapi import FastAPI
1414
from fastapi.middleware.cors import CORSMiddleware
15+
from fastapi.openapi.docs import get_swagger_ui_html
16+
from fastapi.staticfiles import StaticFiles
1517
from mangum import Mangum
1618
from starlette.middleware.sessions import SessionMiddleware
1719

@@ -27,14 +29,18 @@
2729
"""
2830

2931
app = FastAPI(
30-
redoc_url=None, # Disable redoc, keep only swagger
32+
redoc_url=None,
33+
docs_url=None,
3134
title="SoleSearch",
3235
version=__version__,
33-
contact={"name": "SoleSearch Emails Support", "email": "support@solesearch.io"},
36+
contact={"name": "SoleSearch Email Support", "email": "support@solesearch.io"},
3437
description=desc,
3538
responses={404: {"description": "Not found"}}, # Custom 404 page
3639
)
3740

41+
# Serve static files from the /static directory
42+
app.mount("/static", StaticFiles(directory="static"), name="static")
43+
3844
# Enable CORS
3945
app.add_middleware(
4046
CORSMiddleware,
@@ -59,6 +65,16 @@ async def startup_event():
5965
app.include_router(auth.router)
6066

6167

68+
@app.get("/docs", include_in_schema=False)
69+
async def swagger_ui_html():
70+
return get_swagger_ui_html(
71+
openapi_url=app.openapi_url,
72+
title=app.title + " - Documentation",
73+
oauth2_redirect_url=app.swagger_ui_oauth2_redirect_url,
74+
swagger_favicon_url="/static/favicon.png",
75+
)
76+
77+
6278
# This is the entry point for AWS Lambda
6379
handler = Mangum(app)
6480

static/favicon.png

2.43 KB
Loading

0 commit comments

Comments
 (0)