mirror of
https://github.com/Textualize/textual-serve.git
synced 2025-10-17 02:50:37 +03:00
Handler for download/key
This commit is contained in:
@@ -140,6 +140,7 @@ class Server:
|
|||||||
ROUTES = [
|
ROUTES = [
|
||||||
web.get("/", self.handle_index, name="index"),
|
web.get("/", self.handle_index, name="index"),
|
||||||
web.get("/ws", self.handle_websocket, name="websocket"),
|
web.get("/ws", self.handle_websocket, name="websocket"),
|
||||||
|
web.get("/download/{key}", self.handle_download, name="download"),
|
||||||
web.static("/static", self.statics_path, show_index=True, name="static"),
|
web.static("/static", self.statics_path, show_index=True, name="static"),
|
||||||
]
|
]
|
||||||
app.add_routes(ROUTES)
|
app.add_routes(ROUTES)
|
||||||
@@ -148,6 +149,11 @@ class Server:
|
|||||||
app.on_shutdown.append(self.on_shutdown)
|
app.on_shutdown.append(self.on_shutdown)
|
||||||
return app
|
return app
|
||||||
|
|
||||||
|
async def handle_download(self, request: web.Request) -> web.Response:
|
||||||
|
"""Handle a download request."""
|
||||||
|
key = request.match_info["key"]
|
||||||
|
return web.Response()
|
||||||
|
|
||||||
async def on_shutdown(self, app: web.Application) -> None:
|
async def on_shutdown(self, app: web.Application) -> None:
|
||||||
"""Called on shutdown.
|
"""Called on shutdown.
|
||||||
|
|
||||||
@@ -265,6 +271,8 @@ class Server:
|
|||||||
async def handle_websocket(self, request: web.Request) -> web.WebSocketResponse:
|
async def handle_websocket(self, request: web.Request) -> web.WebSocketResponse:
|
||||||
"""Handle the websocket that drives the remote process.
|
"""Handle the websocket that drives the remote process.
|
||||||
|
|
||||||
|
This is called when the browser connects to the websocket.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
request: Request object.
|
request: Request object.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user