view.run.servers

Magically run applications on some common servers.

Classes

ServerSettings(app, port, host[, hint])

Dataclass representing server settings that can be used to start serving an app.

Exceptions

BadServerError(*msg)

Something is wrong with the selected server.

exception BadServerError(*msg: str)

Bases: ViewError

Something is wrong with the selected server.

This generally means that the target server isn’t installed or doesn’t exist (either not supported by view.py or there’s a typo present).

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class ServerSettings(app: BaseApp, port: int, host: str, hint: str | None = None)

Bases: object

Dataclass representing server settings that can be used to start serving an app.

AVAILABLE_SERVERS: ClassVar[Sequence[str]] = ['uvicorn', 'hypercorn', 'daphne', 'gunicorn', 'werkzeug', 'wsgiref']
app: BaseApp
hint: str | None
host: str
port: int
run_app_on_any_server() None

Run the app on the nearest available ASGI or WSGI server.

This will always succeed, as it will fall back to the standard wsgiref module if no other server is installed.

run_daphne() None

Run the app using the daphne library.

run_gunicorn() None

Run the app using the gunicorn library.

run_hypercorn() None

Run the app using the hypercorn library.

run_uvicorn() None

Run the app using the uvicorn library.

run_werkzeug() None

Run the app using the werkzeug library.

run_wsgiref() None

Run the app using the built-in wsgiref module.