app
This module contains all the utilities to launch a WSGI micro server (highly recommended in production mode).
uApp Objects
class uApp()
Represents a lightweight application server that can handle HTTP requests, optionally wrap its socket with SSL, and run in a testing mode.
Attributes:
handlerBaseHTTPRequestHandler - HTTP request handler.hoststr - The hostname for the server.portint - The port number for the server.
uApp.__init__
def __init__(host: str = "127.0.0.1",
port: int = 5000,
loglevel: int = 20,
handler: BaseHTTPRequestHandler = route.uHTTPRequestHandler)
Initializes the uApp instance with a specified host, port, logging level, and request handler.
Arguments:
hoststr - Hostname for the server. Defaults to “127.0.0.1”.portint - Port number for the server. Defaults to 5000.loglevelint - Logging level. Defaults to 20 (INFO).handlerBaseHTTPRequestHandler - Request handler. Defaults toroute.uHTTPRequestHandler.
uApp.__call__
def __call__(environ: dict, start_response: Callable) -> bytes
Enables the application to be callable as a WSGI application.
Arguments:
environdict - The WSGI environment dictionary.start_responsecallable - A callable to start the HTTP response.
Returns:
Callable- The response iterable.
uApp.wrap
def wrap() -> bool
Wraps the HTTP server’s socket with SSL if a certificate and key are available.
Returns:
bool- True if the socket is successfully wrapped with SSL, False otherwise.
uApp.run
def run(ssl: bool = False)
Starts the HTTP server, optionally wrapping the socket with SSL. This method is designed for testing purposes only.
Arguments:
sslbool - If True, wraps the server’s socket with SSL. Defaults to False.