Skip to main content

ASF Quart Framework

Project description

asfquart - a Quart framework for the ASF

PyPI PyPI - Python Versions Unit Tests Apache License

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
  • Identity management (replaces the old id.a.o)
  • Gitbox UI
  • ??

Primer

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()

Installation

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]"

Building asfquart package

Prerequisites:

  • poetry: install e.g. with pipx pipx install poetry

Building the package:

$ poetry build

Running the tests:

$ poetry run pytest

Examples

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

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

asfquart-0.1.12.tar.gz (22.0 kB view details)

Uploaded Source

Built Distribution

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

asfquart-0.1.12-py3-none-any.whl (24.3 kB view details)

Uploaded Python 3

File details

Details for the file asfquart-0.1.12.tar.gz.

File metadata

  • Download URL: asfquart-0.1.12.tar.gz
  • Upload date:
  • Size: 22.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.3 Linux/6.6.76-08096-g300882a0a131

File hashes

Hashes for asfquart-0.1.12.tar.gz
Algorithm Hash digest
SHA256 ddbf7bab454ab8e6dca27649b227ab365bd4084f6e5a3271a6e15c51a9af9640
MD5 eb55140750cb0413b42d741868a662f6
BLAKE2b-256 9e5f5d67a6511f727794a36417a84f695796a609a627edbd89691facdc33bd76

See more details on using hashes here.

File details

Details for the file asfquart-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: asfquart-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 24.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.3 Linux/6.6.76-08096-g300882a0a131

File hashes

Hashes for asfquart-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 80ec03522cc8b0ce17e5a91af077d6a4b6557b35fb274816f97a02890be0f678
MD5 7ad2ff0d1edc0d2f252863bdf51d7c37
BLAKE2b-256 9cc58969e7aa06d448ffe9492a203e956717c4f7bc286602580a27141416adda

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