repos: 228485806
This data as json
id | node_id | name | full_name | private | owner | html_url | description | fork | created_at | updated_at | pushed_at | homepage | size | stargazers_count | watchers_count | language | has_issues | has_projects | has_downloads | has_wiki | has_pages | forks_count | archived | disabled | open_issues_count | license | topics | forks | open_issues | watchers | default_branch | permissions | temp_clone_token | organization | network_count | subscribers_count | readme | readme_html | allow_forking | visibility | is_template | template_repository | web_commit_signoff_required | has_discussions |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
228485806 | MDEwOlJlcG9zaXRvcnkyMjg0ODU4MDY= | datasette-configure-asgi | simonw/datasette-configure-asgi | 0 | 9599 | https://github.com/simonw/datasette-configure-asgi | Datasette plugin for configuring arbitrary ASGI middleware | 0 | 2019-12-16T22:17:10Z | 2020-08-25T15:54:32Z | 2019-12-16T22:19:49Z | 6 | 1 | 1 | Python | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | apache-2.0 | ["asgi", "datasette", "datasette-plugin", "datasette-io"] | 0 | 0 | 1 | master | {"admin": false, "push": false, "pull": false} | 0 | 1 | # datasette-configure-asgi [](https://pypi.org/project/datasette-configure-asgi/) [](https://circleci.com/gh/simonw/datasette-configure-asgi) [](https://github.com/simonw/datasette-configure-asgi/blob/master/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: ```json { "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: ```python 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. | <div id="readme" class="md" data-path="README.md"><article class="markdown-body entry-content container-lg" itemprop="text"><h1><a id="user-content-datasette-configure-asgi" class="anchor" aria-hidden="true" href="#user-content-datasette-configure-asgi"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>datasette-configure-asgi</h1> <p><a href="https://pypi.org/project/datasette-configure-asgi/" rel="nofollow"><img src="https://camo.githubusercontent.com/f416823edcf74e9efabbee4be66b7db51784d1eeb1b7fd75286cfcbf16a87815/68747470733a2f2f696d672e736869656c64732e696f2f707970692f762f6461746173657474652d636f6e6669677572652d617367692e737667" alt="PyPI" data-canonical-src="https://img.shields.io/pypi/v/datasette-configure-asgi.svg" style="max-width:100%;"></a> <a href="https://circleci.com/gh/simonw/datasette-configure-asgi" rel="nofollow"><img src="https://camo.githubusercontent.com/d9cd8121c1d308429b1b5c4f9a87aee4091dfe95aadeeb9e39336aa91fb737e4/68747470733a2f2f636972636c6563692e636f6d2f67682f73696d6f6e772f6461746173657474652d636f6e6669677572652d617367692e7376673f7374796c653d737667" alt="CircleCI" data-canonical-src="https://circleci.com/gh/simonw/datasette-configure-asgi.svg?style=svg" style="max-width:100%;"></a> <a href="https://github.com/simonw/datasette-configure-asgi/blob/master/LICENSE"><img src="https://camo.githubusercontent.com/1698104e976c681143eb0841f9675c6f802bb7aa832afc0c7a4e719b1f3cf955/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d417061636865253230322e302d626c75652e737667" alt="License" data-canonical-src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" style="max-width:100%;"></a></p> <p>Datasette plugin for configuring arbitrary ASGI middleware</p> <h2><a id="user-content-installation" class="anchor" aria-hidden="true" href="#user-content-installation"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Installation</h2> <div class="snippet-clipboard-content position-relative" data-snippet-clipboard-copy-content="pip install datasette-configure-asgi "><pre><code>pip install datasette-configure-asgi </code></pre></div> <h2><a id="user-content-usage" class="anchor" aria-hidden="true" href="#user-content-usage"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Usage</h2> <p>This plugin only takes effect if your <code>metadata.json</code> file contains relevant top-level plugin configuration in a <code>"datasette-configure-asgi"</code> configuration key.</p> <p>For example, to wrap your Datasette instance in the <code>asgi-log-to-sqlite</code> middleware configured to write logs to <code>/tmp/log.db</code> you would use the following:</p> <div class="highlight highlight-source-json position-relative" data-snippet-clipboard-copy-content="{ "plugins": { "datasette-configure-asgi": [ { "class": "asgi_log_to_sqlite.AsgiLogToSqlite", "args": { "file": "/tmp/log.db" } } ] } } "><pre>{ <span class="pl-s"><span class="pl-pds">"</span>plugins<span class="pl-pds">"</span></span>: { <span class="pl-s"><span class="pl-pds">"</span>datasette-configure-asgi<span class="pl-pds">"</span></span>: [ { <span class="pl-s"><span class="pl-pds">"</span>class<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>asgi_log_to_sqlite.AsgiLogToSqlite<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>args<span class="pl-pds">"</span></span>: { <span class="pl-s"><span class="pl-pds">"</span>file<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>/tmp/log.db<span class="pl-pds">"</span></span> } } ] } }</pre></div> <p>The <code>"datasette-configure-asgi"</code> key should be a list of JSON objects. Each object should have a <code>"class"</code> key indicating the class to be used, and an optional <code>"args"</code> key providing any necessary arguments to be passed to that class constructor.</p> <h2><a id="user-content-plugin-structure" class="anchor" aria-hidden="true" href="#user-content-plugin-structure"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Plugin structure</h2> <p>This plugin can be used to wrap your Datasette instance in any ASGI middleware that conforms to the following structure:</p> <div class="highlight highlight-source-python position-relative" data-snippet-clipboard-copy-content="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)) "><pre><span class="pl-k">class</span> <span class="pl-v">SomeAsgiMiddleware</span>: <span class="pl-k">def</span> <span class="pl-en">__init__</span>(<span class="pl-s1">self</span>, <span class="pl-s1">app</span>, <span class="pl-s1">arg1</span>, <span class="pl-s1">arg2</span>): <span class="pl-s1">self</span>.<span class="pl-s1">app</span> <span class="pl-c1">=</span> <span class="pl-s1">app</span> <span class="pl-s1">self</span>.<span class="pl-s1">arg1</span> <span class="pl-c1">=</span> <span class="pl-s1">arg1</span> <span class="pl-s1">self</span>.<span class="pl-s1">arg2</span> <span class="pl-c1">=</span> <span class="pl-s1">arg2</span> <span class="pl-k">async</span> <span class="pl-k">def</span> <span class="pl-en">__call__</span>(<span class="pl-s1">self</span>, <span class="pl-s1">scope</span>, <span class="pl-s1">receive</span>, <span class="pl-s1">send</span>): <span class="pl-s1">start</span> <span class="pl-c1">=</span> <span class="pl-s1">time</span>.<span class="pl-en">time</span>() <span class="pl-k">await</span> <span class="pl-s1">self</span>.<span class="pl-en">app</span>(<span class="pl-s1">scope</span>, <span class="pl-s1">receive</span>, <span class="pl-s1">send</span>) <span class="pl-s1">end</span> <span class="pl-c1">=</span> <span class="pl-s1">time</span>.<span class="pl-en">time</span>() <span class="pl-en">print</span>(<span class="pl-s">"Time taken: {}"</span>.<span class="pl-en">format</span>(<span class="pl-s1">end</span> <span class="pl-c1">-</span> <span class="pl-s1">start</span>))</pre></div> <p>So the middleware is a class with a constructor which takes the wrapped application as a first argument, <code>app</code>, followed by further named arguments to configure the middleware. It provides an <code>async def __call__(self, scope, receive, send)</code> method to implement the middleware's behavior.</p> </article></div> |
Links from other tables
- 0 rows from repo in releases