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:
APP
config.yaml
Current (known, public) users of asfquart:
Future users of asfquart:
See the documentation page for more information.
import asfquart from asfquart.auth import Requirements as R def my_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("/") async def homepage(): return "Hello!" @app.route("/secret") @asfquart.auth.require(R.committer) async def secret_page(): return "Secret stuff!" return app if __name__ == "__main__": app = my_app() # Run the application in an extended debug mode: # - reload the app when any source / config file get changed app.runx(port=8000) else: # Serve the application via an ASGI server, e.g. hypercorn app = my_app()
Create and activate a virtual environment and then install asfquart
using pip:
$ pip install "asfquart"
Note: Adding the [aioldap]
extra will install optional dependencies for LDAP support that will require additional system dependencies:
$ pip install "asfquart[aioldap]"
Prerequisites:
poetry
: install e.g. with pipx pipx install poetry
Building the package:
$ poetry build
Running the tests:
$ poetry run pytest
There 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-dev
to run it with an ASGI server for production, type:
$ make example-run