Ejemplo n.º 1
0
async def http_exception(request, exc):
    url = urlparse(str(request.url))
    if not url.path.startswith("/api/v1"):
        if (Path(webui_dir("dist")).is_dir()
                and Path(webui_dir(join("dist", "index.html"))).is_file()):
            return FileResponse(webui_dir(join("dist", "index.html")))
    return JSONResponse({"detail": "Not Found"}, status_code=404)
Ejemplo n.º 2
0
 async def webui_index():
     return FileResponse(webui_dir(join("dist", "index.html")))
Ejemplo n.º 3
0
async def webui_redir():
    return RedirectResponse(url="/landing/", status_code=302)


# served by nginx
if Path(landing_dir("index.html")).is_file():
    logger.info("[email protected] - Registering landing routers")

    @api.get("/landing/")
    async def web_index():
        return FileResponse(landing_dir("index.html"))

    api.mount("/landing", StaticFiles(directory=landing_dir()))

# served by nginx
if Path(webui_dir("dist")).is_dir():
    logger.info("[email protected] - Registering webui routers")

    # served by nginx
    @api.get("/webui")
    async def webui_redir():
        return RedirectResponse(url="/webui/", status_code=302)

    # served by nginx w/ slight rewrite
    @api.get("/webui/assets")
    async def webui_index():
        return FileResponse(webui_dir(join("dist", "index.html")))

    api.mount("/webui/assets", StaticFiles(directory=webui_dir("dist")))

logger.debug("[email protected] - Registering 404 handler")