Skip to main content

datasette-configure-asgi

PyPI CircleCI License

Datasette plugin for configuring arbitrary ASGI middleware

Installation

pip install datasette-configure-asgi

Usage

This plugin only takes effect if your metadata.json file contains relevant top-level plugin configuration in a "datasette-configure-asgi" configuration key.

For example, to wrap your Datasette instance in the asgi-log-to-sqlite middleware configured to write logs to /tmp/log.db you would use the following:

{
    "plugins": {
        "datasette-configure-asgi": [
            {
                "class": "asgi_log_to_sqlite.AsgiLogToSqlite",
                "args": {
                    "file": "/tmp/log.db"
                }
            }
        ]
    }
}

The "datasette-configure-asgi" key should be a list of JSON objects. Each object should have a "class" key indicating the class to be used, and an optional "args" key providing any necessary arguments to be passed to that class constructor.

Plugin structure

This plugin can be used to wrap your Datasette instance in any ASGI middleware that conforms to the following structure:

class SomeAsgiMiddleware:
    def __init__(self, app, arg1, arg2):
        self.app = app
        self.arg1 = arg1
        self.arg2 = arg2

    async def __call__(self, scope, receive, send):
        start = time.time()
        await self.app(scope, receive, send)
        end = time.time()
        print("Time taken: {}".format(end - start))

So the middleware is a class with a constructor which takes the wrapped application as a first argument, app, followed by further named arguments to configure the middleware. It provides an async def __call__(self, scope, receive, send) method to implement the middleware's behavior.

Metadata

Release files for datasette-configure-asgi 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for datasette-configure-asgi 0.1
File Interpreter ABI Platform Actions
datasette_configure_asgi-0.1-py3-none-any.whl Python 3 none any Details for datasette_configure_asgi-0.1-py3-none-any.whl

Release files / datasette_configure_asgi-0.1-py3-none-any.whl

Download URL datasette_configure_asgi-0.1-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2061cf5184f5d9aaa7909f6fef54702c2595fcc731bdd4472518c07ce3fa8cb2
BLAKE2b-256 checksum
How to use checksums
f776c2ae1907ff0c5e8f3366c2041c1d73019b7825d6948ce880eb3ddf60be20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.6.9

Security for datasette-configure-asgi 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page