mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
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:
parent
35429f9089
commit
ba8db9679f
19 changed files with 1510 additions and 947 deletions
|
|
@ -1,10 +1,9 @@
|
|||
import os
|
||||
|
||||
from sanic import response
|
||||
|
||||
from datasette.utils import to_css_class, validate_sql_select
|
||||
from datasette.utils.asgi import AsgiFileDownload
|
||||
|
||||
from .base import DataView, DatasetteError
|
||||
from .base import DatasetteError, DataView
|
||||
|
||||
|
||||
class DatabaseView(DataView):
|
||||
|
|
@ -79,8 +78,8 @@ class DatabaseDownload(DataView):
|
|||
if not db.path:
|
||||
raise DatasetteError("Cannot download database", status=404)
|
||||
filepath = db.path
|
||||
return await response.file_stream(
|
||||
return AsgiFileDownload(
|
||||
filepath,
|
||||
filename=os.path.basename(filepath),
|
||||
mime_type="application/octet-stream",
|
||||
content_type="application/octet-stream",
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue