feat: support direct links to guild views
This commit is contained in:
2 files changed
+35
-3
No files matched your search
@@ -8,6 +8,7 @@ from contextlib import asynccontextmanager
|
||||
|
||||
import uvicorn
|
||||
from fastapi import FastAPI
|
||||
from fastapi.responses import FileResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
from zyrarbot.audio.media_probe import MediaProbe
|
||||
@@ -80,6 +81,12 @@ class Application:
|
||||
self.web.router.lifespan_context = lifespan
|
||||
|
||||
os.makedirs(self.settings.static_dir, exist_ok=True)
|
||||
|
||||
@self.web.get("/{guild_route}", include_in_schema=False)
|
||||
async def guild_panel(guild_route: str) -> FileResponse:
|
||||
"""Serve the SPA for a direct link to a guild view."""
|
||||
return FileResponse(os.path.join(self.settings.static_dir, "index.html"))
|
||||
|
||||
self.web.mount(
|
||||
"/", StaticFiles(directory=self.settings.static_dir, html=True), name="static"
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user