run
Universal entry point that detects the execution environment and starts the server accordingly. In standard server mode it launches uvicorn; in serverless environments (AWS Lambda, CGI) it processes the incoming request and returns a response.
This method blocks in server mode. For production deployments behind gunicorn or
another ASGI server, use server.app directly instead of calling run().
Parameters
event
Serverless event object (AWS Lambda, Google Cloud Functions). Pass the Lambda handler’s
event parameter here. Ignored in server mode.
context
Serverless context object (AWS Lambda, Google Cloud Functions). Pass the Lambda handler’s
context parameter here. Ignored in server mode.
host
Override the host set in the constructor. Only applies in server mode.
port
Override the port set in the constructor. Only applies in server mode.
Returns
None in server mode (blocks until shutdown). In Lambda mode, returns a response dict
with statusCode, headers, and body. In CGI mode, returns the formatted response string.
Examples
Server Mode
AWS Lambda
Gunicorn (external ASGI server)
If SWML_SSL_ENABLED is set to true in the environment along with SWML_SSL_CERT_PATH
and SWML_SSL_KEY_PATH, the server starts with HTTPS automatically.