This is a Quart framework for ASF web applications.
On top of Quart, this package layers a lot of functionality, much of which is specific to the ASF and its infrastructure and preferred approaches for website application development.
asfquart adds the following items to basic quart:
- simple construction of the
APP - default
config.yaml - watching the .py and config for changes, to cause a restart/reload
- watch SIGINT to halt and SIGUSR2 to restart/reload
- template watching and rendering for EZT templates
- URL path routing for pages and API endpoints
- Oauth with our ASF provider for authn
- LDAP group testing for authz
- long-running tasks and their lifecycle management
Current (known, public) users of asfquart:
Future users of asfquart:
- Apache STeVe
- ASF Identity management
- ASF GitBox UI
- others, to be listed
See the documentation page for more information.
importasfquartfromasfquart.authimportRequirementsasRdefmy_app() ->asfquart.base.QuartApp:
# Construct the quart service. By default, the oauth gateway is enabled at /oauth.app=asfquart.construct("my_app_service")
@app.route("/")asyncdefhomepage():
return"Hello!"@app.route("/secret")@asfquart.auth.require(R.committer)asyncdefsecret_page():
return"Secret stuff!"returnappif__name__=="__main__":
app=my_app()
# Run the application in an extended debug mode:# - reload the app when any source / config file get changedapp.runx(port=8000)
else:
# Serve the application via an ASGI server, e.g. hypercornapp=my_app()Create and activate a virtual environment and then install asfquart using uv or pip:
# With uv
uv add asfquart
# With uv pip-compatible interface
uv pip install asfquart
# With standard pip
pip install asfquartNote: Adding the [aioldap] extra will install optional dependencies for LDAP support that will
require additional system dependencies:
# With uv
uv add asfquart --extra aioldap
# With uv pip-compatible interface
uv pip install "asfquart[aioldap]"# With standard pip
pip install "asfquart[aioldap]"Install the required dependencies for development:
uv syncInstall the optional dependencies for development:
uv sync --extra aioldapRunning the tests:
uv sync --all-extras --group test
uv run pytestBuilding the package:
uv buildThere is a simple test application included (./examples/snippets/simple_app.py) to outline the basic setup.
To run the application in development mode, type:
make example-devto run it with an ASGI server for production, type:
make example-run