servo/tests/wpt/web-platform-tests/docs/writing-tests/python-handlers/index.md

649 B

Python Handlers

Python file handlers are Python files which the server executes in response to requests made to the corresponding URL. This is hooked up to a route like ("*", "*.py", python_file_handler), meaning that any .py file will be treated as a handler file (note that this makes it easy to write unsafe handlers, particularly when running the server in a web-exposed setting).

The Python files must define a single function main with the signature::

main(request, response)

The wptserver implements a number of Python APIs for controlling traffic.

.. toctree::
   :maxdepth: 1

   request
   response
   stash