kopia lustrzana https://github.com/simonw/datasette
Support OPTIONS without 500, closes #1001
rodzic
703439bdc3
commit
7249ac5ca0
|
@ -110,6 +110,9 @@ class BaseView:
|
||||||
def database_color(self, database):
|
def database_color(self, database):
|
||||||
return "ff0000"
|
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):
|
async def dispatch_request(self, request, *args, **kwargs):
|
||||||
handler = getattr(self, request.method.lower(), None)
|
handler = getattr(self, request.method.lower(), None)
|
||||||
return await handler(request, *args, **kwargs)
|
return await handler(request, *args, **kwargs)
|
||||||
|
|
|
@ -52,6 +52,12 @@ def test_http_head(app_client):
|
||||||
assert response.status == 200
|
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):
|
def test_favicon(app_client):
|
||||||
response = app_client.get("/favicon.ico")
|
response = app_client.get("/favicon.ico")
|
||||||
assert response.status == 200
|
assert response.status == 200
|
||||||
|
|
Ładowanie…
Reference in New Issue