wsgi_app

CircuitPython framework for creating WSGI server compatible web applications. This does not include server implementation, which is necessary in order to create a web application with this library.

Implementation Notes

Software and Dependencies:

class adafruit_wsgi.wsgi_app.WSGIApp

The base WSGI Application class.

on_request(methods: List[str], rule: str, request_handler: Callable)

Register a Request Handler for a particular HTTP method and path. request_handler will be called whenever a matching HTTP request is received.

request_handler should accept the following args:

(Dict environ)

request_handler should return a tuple in the shape of:

(status, header_list, data_iterable)

Parameters:
  • methods (list) – the methods of the HTTP request to handle

  • rule (str) – the path rule of the HTTP request

  • request_handler (func) – the function to call

route(rule: str, methods: List[str] | None = None)

A decorator to register a route rule with an endpoint function. if no methods are provided, default to GET

Request

  • Author(s): Matthew Costi

class adafruit_wsgi.request.Request(environ: Dict[str, str])

An incoming HTTP request. A higher level abstraction of the raw WSGI Environ dictionary.

property body

The Request Body

property headers: Dict[str, str]

Request headers, represented as a dictionary of header name to header value

property method: str

the HTTP Method Type of this request

property path: str

the path this request was made to

property query_params: Dict[str, str]

Request query parameters, represented as a dictionary of param name to param value

property wsgi_environ: Dict[str, str]

The raw WSGI Environment dictionary representation of the request