svc: Add navigate operation
The *POST /screen/{name}/navigate* path operation allows the client to
request the screen navigate to a different URL, specified by the `url`
form field.
This commit is contained in:
@@ -126,6 +126,14 @@ async def get_screenshot(
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
@app.post(
|
||||||
|
'/screen/{name}/navigate',
|
||||||
|
response_class=fastapi.responses.PlainTextResponse,
|
||||||
|
)
|
||||||
|
async def navigate(name: str, url: str = fastapi.Form(...)):
|
||||||
|
await svc.navigate(name, url)
|
||||||
|
|
||||||
|
|
||||||
@app.on_event('shutdown')
|
@app.on_event('shutdown')
|
||||||
async def on_shutdown():
|
async def on_shutdown():
|
||||||
await svc.shutdown()
|
await svc.shutdown()
|
||||||
|
|||||||
@@ -116,6 +116,12 @@ class HUDService:
|
|||||||
dict,
|
dict,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
async def navigate(self, name: str, url: str) -> None:
|
||||||
|
assert self.marionette
|
||||||
|
async with self.lock:
|
||||||
|
await self.marionette.switch_to_window(self.windows[name])
|
||||||
|
await self.marionette.navigate(url)
|
||||||
|
|
||||||
async def refresh_screen(self, name: str) -> None:
|
async def refresh_screen(self, name: str) -> None:
|
||||||
assert self.marionette
|
assert self.marionette
|
||||||
async with self.lock:
|
async with self.lock:
|
||||||
|
|||||||
Reference in New Issue
Block a user