Source code for django_prodserver.backends.servers.uvicorn

import uvicorn.main

from ...utils import asgi_app_name, wsgi_app_name
from ..base import BaseServerBackend


[docs] class UvicornServer(BaseServerBackend): """ Uvicorn ASGIServer Backend. This bypasses any Django handling of the command and sends all arguments straight to uvicorn. """
[docs] def prep_server_args(self) -> list[str]: """Prepare the server args.""" args = [asgi_app_name()] args.extend(self.args) return args
[docs] def start_server(self, *args: str) -> None: """Start the server.""" uvicorn.main.main(args)
[docs] class UvicornWSGIServer(BaseServerBackend): """ Uvicorn WSGIServer Backend. This bypasses any Django handling of the command and sends all arguments straight to uvicorn. """
[docs] def prep_server_args(self) -> list[str]: """Prepare the server args.""" args = [wsgi_app_name(), "--interface=wsgi"] args.extend(self.args) return args
[docs] def start_server(self, *args: str) -> None: """Start the server.""" uvicorn.main.main(args)