1chooo / refinaid

🐻 Enabling everyone unfamiliar with programming languages to easily engage with AI and open the doors to the world of the future. (AI4ALL)
https://refinaid.vercel.app/
Apache License 2.0
21 stars 5 forks source link

[Wiki] Setting favicon with FastAPI #141

Open 1chooo opened 1 year ago

1chooo commented 1 year ago
PROJECT_ROOT
├── static/
│   ├── favicon.ico
├── Refinaid/
│   ├── App/
│   │   ├── app.py
│   :
└── :

In the below of our project structure, if we want to set a favicon for all pages we can add the below code in Refinaid.App.app and remember to add include_in_schema=False included in the decorator hides the path operation from the schema used to autogenerate API docs.

@app.get('/favicon.ico', include_in_schema=False)
async def favicon() -> FileResponse:
    return FileResponse(
        './static/favicon_path',
    )