tree: 57c5db74f6333533f565c5ebd09a37de6ca2ccf8 [search]
  1. app-secret.md
  2. auth.md
  3. external-services.md
  4. forms.md
  5. input-validation.md
  6. limits.md
  7. oauth.md
  8. one-process.md
  9. README.md
  10. reverse-proxy.md
  11. session-stores.md
  12. sessions.md
  13. templates.md
docs/README.md

Bootstrapping asfquart

Constructing the base quart app

import asfquart


def main():
    app = asfquart.construct("name_of_app")
    return app


if __name__ == "__main__":
    app = main()
    # run a development server on port 8080
    app.runx(port=8080)

Other modules in the app will use:

import asfquart

APP = asfquart.APP


@APP.some_decorator
async def some_endpoint():
    return do_something()

asfquart.APP is None until construct() has been called, though it is typed as the app. Code that also runs in a process with no app, such as a worker or a script, calls asfquart.app_or_none(), which is typed as returning the app or None:

app = asfquart.app_or_none()
if app is not None:
    app.add_background_task(notify)

One process

An asfquart application runs as one process: one instance, served by one worker. Do not give the ASGI server more than one worker, and do not run several instances of an application behind a load balancer. One process explains which parts of asfquart assume this, what goes wrong otherwise, and what would have to change to support more.

See also (WIP):