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:
handler
BaseHTTPRequestHandler - HTTP request handler.host
str - The hostname for the server.port
int - 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:
host
str - Hostname for the server. Defaults to “127.0.0.1”.port
int - Port number for the server. Defaults to 5000.loglevel
int - Logging level. Defaults to 20 (INFO).handler
BaseHTTPRequestHandler - 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:
environ
dict - The WSGI environment dictionary.start_response
callable - 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:
ssl
bool - If True, wraps the server’s socket with SSL. Defaults to False.