Port Datasette from Sanic to ASGI + Uvicorn (#518)

Datasette now uses ASGI internally, and no longer depends on Sanic.

It now uses Uvicorn as the underlying HTTP server.

This was thirteen months in the making... for full details see the issue:

https://github.com/simonw/datasette/issues/272

And for a full sequence of commits plus commentary, see the pull request:

https://github.com/simonw/datasette/pull/518
This commit is contained in:
Simon Willison 2019-06-23 20:13:09 -07:00 committed by GitHub
commit ba8db9679f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 1510 additions and 947 deletions

View file

@ -1,9 +1,8 @@
import hashlib
import json
from sanic import response
from datasette.utils import CustomJSONEncoder
from datasette.utils.asgi import Response
from datasette.version import __version__
from .base import BaseView
@ -104,9 +103,9 @@ class IndexView(BaseView):
headers = {}
if self.ds.cors:
headers["Access-Control-Allow-Origin"] = "*"
return response.HTTPResponse(
return Response(
json.dumps({db["name"]: db for db in databases}, cls=CustomJSONEncoder),
content_type="application/json",
content_type="application/json; charset=utf-8",
headers=headers,
)
else: