webstation-broker
DeveloperPython reference

app

FastAPI application factory.

FastAPI application factory.

The app is mounted under settings.PREFIX (default /streaming) so the same paths work behind nginx, a reverse proxy, or uvicorn directly. Outside dev mode the built frontend is served as static files at the prefix root; in dev mode vite serves the frontend instead.

func_lifespan(_app) -> AsyncIterator[None]

Reap an emulator orphaned by a previous broker process before serving.

A fresh broker holds no session, so an emulator recorded by the process that came before is playing to nobody. Killing it here rather than at the next activate is what keeps it killable at all: exit answers 409 without a session, so otherwise the only way out is launching another game.

Yields

  • AsyncIterator[None]: Nothing; control passes to the running application once the orphan is reaped.
param_appFastAPI

The application being started; unused.

Returns

collections.abc.AsyncIterator[None]
funccreate_app() -> FastAPI

Build the broker application, mounted under the configured prefix.

The lifespan belongs to whichever app is actually served. Starlette never hands the lifespan scope to a mounted sub-app, so a startup hook on the inner app would silently never run behind a prefix.

Returns

fastapi.FastAPI

The application to serve: a bare root app with the broker mounted at