405 method not allowed for GET to POST endpoints, closes #1916

This commit is contained in:
Simon Willison 2022-11-29 21:15:13 -08:00
commit 8404b21556
2 changed files with 26 additions and 1 deletions

View file

@ -69,7 +69,6 @@ class BaseView:
return "ff0000"
async def method_not_allowed(self, request):
print(request.headers)
if (
request.path.endswith(".json")
or request.headers.get("content-type") == "application/json"
@ -82,6 +81,9 @@ class BaseView:
async def options(self, request, *args, **kwargs):
return await self.method_not_allowed(request)
async def get(self, request, *args, **kwargs):
return await self.method_not_allowed(request)
async def post(self, request, *args, **kwargs):
return await self.method_not_allowed(request)