Skip to content

Commit

Permalink
Support OPTIONS without 500, closes #1001
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Oct 9, 2020
1 parent 703439b commit 7249ac5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions datasette/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ def database_url(self, database):
def database_color(self, database):
return "ff0000"

async def options(self, request, *args, **kwargs):
return Response.text("Method not allowed", status=405)

async def dispatch_request(self, request, *args, **kwargs):
handler = getattr(self, request.method.lower(), None)
return await handler(request, *args, **kwargs)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ def test_http_head(app_client):
assert response.status == 200


def test_homepage_options(app_client):
response = app_client.get("/", method="OPTIONS")
assert response.status == 405
assert response.text == "Method not allowed"


def test_favicon(app_client):
response = app_client.get("/favicon.ico")
assert response.status == 200
Expand Down

0 comments on commit 7249ac5

Please sign in to comment.