File size: 527 Bytes
a55ea57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from starlette.exceptions import HTTPException
from starlette.staticfiles import StaticFiles


def is_console_path(path: str) -> bool:
    return path == "/console" or path.startswith("/console/")


class SPAStaticFiles(StaticFiles):
    async def get_response(self, path: str, scope):
        try:
            return await super().get_response(path, scope)
        except HTTPException as exc:
            if exc.status_code == 404:
                return await super().get_response("index.html", scope)
            raise exc