2022-05-29 00:31:32 +02:00

15 lines
398 B
Python

import typing
from fastapi.staticfiles import StaticFiles
class SPAStaticFiles(StaticFiles):
async def get_response(self, path: str, scope: typing.Any):
response = await super().get_response(path, scope)
# Default back to `index.html` for our SPA
if response.status_code == 404:
response = await super().get_response(".", scope)
return response