Skip to main content

Web API Utils for Werkzeug

Project description

wau - Web API Utils

Web API Utils, or short wau, is a thin layer on top of Werkzeug to provide a simple and consistent interface for writing APIs in Python. wau is built for educational purposes and is not intended for production use. It is opinionated, as it only supports JSON as data format. It uses simple type annotations to define the expected input and output of the API endpoints. Common tasks as authentication, CORS and server-sent events are supported out of the box.

Installation

Install from PyPI:

pip install wau

or with uv:

uv add wau

Serving static files

run() can serve a static front-end next to your API. Pass static=True to serve files from the directory of the calling script, or static="some/dir" to serve a specific directory:

from wau import run

run(api, static=True)

Only an allow-listed set of file types is served by default (HTML, CSS, JavaScript, images, fonts, ...), so source code and dotfiles such as .env are never exposed. Adjust the allowed file-name globs with static_include and static_exclude (static_exclude takes precedence):

run(api, static=True, static_include=("*.html", "*.css", "*.js"))

While static serving is enabled, the served pages reload automatically in the browser whenever a file changes. This uses the optional watchdog package when it is installed and falls back to polling otherwise. Both this browser reload and Werkzeug's Python source reloader are controlled by use_reloader (on by default); set use_reloader=False to disable them.

Testing

Test dependencies are separated from runtime dependencies in pyproject.toml using the test dependency group.

Run the test suite:

uv run --group test python -m pytest -q

Run doctests:

uv run --group test python -m doctest .\wau.py

Publishing

Build package artifacts:

uv build

Validate metadata and README rendering:

uvx twine check dist/*

Upload to TestPyPI first:

uv publish --publish-url https://test.pypi.org/legacy/

Then publish to PyPI:

uv publish

License

This project is licensed under GNU LGPL v3 or later (LGPL-3.0-or-later).

If you distribute modified versions of this library, those library modifications must be published under the same license terms.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wau-0.1.3.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wau-0.1.3-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file wau-0.1.3.tar.gz.

File metadata

  • Download URL: wau-0.1.3.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for wau-0.1.3.tar.gz
Algorithm Hash digest
SHA256 3e39096222fc27f440f63ca81ca5f4f697ef9f39d6fccfc0bf840c6f19a0e90f
MD5 a3b4032ff0c77302a4175fc06e358941
BLAKE2b-256 eed803055bda4668ff993781012043581f05a6c967f2df6be55c8271462f51d9

See more details on using hashes here.

File details

Details for the file wau-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: wau-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for wau-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 decc3a6b1536ec3fc57fb3194d4935b2ee12cf542037a918e28aa62b9ef7e637
MD5 e065a362b947de1101eeaf2e6fbadc87
BLAKE2b-256 c17d005a86f81e2cf6051755bce2d62d2e7fb8518ca450559171e0cdb7d6d94b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page