I'm new to Django so please excuse me if this is a silly question. I'm trying to create a very simple REST API where a file gets sent via POST and Django returns a json string.
Here is my code in views.py:
def evaluate(request):
return HttpResponse(json.dumps({"hello world": 123}))
And in urls.py:
urlpatterns = [
url(r'^evaluate/$', csrf_exempt(views.evaluate), name='evaluate'),
]
When I do a GET request to /evaluate/ I get back {"hello world": 123}
, however I receive a blank response when I send the exact same request as a POST.
Any ideas how I can have POST requests return the JSON as well?
答案 0 :(得分:0)
我做了一些进一步的调查,发现Chrome上的CORS导致了这个问题。这是解决方案的链接:https://stackoverflow.com/a/30956822/563762