Internal server error 500 on heroku Django by sending an AJAX request

天涯浪子 提交于 2019-12-25 03:35:10

问题


This is a follow up question from: How do I make a loading page while I am processing something in the backend with Django?

I am performing some calculations in the view method. Thus it takes 2~4 seconds to initiate a return statement from my view.py's function verify_api().

I get internal server error when the web application has been deployed to heroku.

From heroku logs :

2015-05-15T21:35:47.907877+00:00 heroku[router]: at=info method=GET path="/verify_api" host=todjoke.herokuapp.com request_id=1765d59f-e57e-4f6c-b75e-1552023f8e9c fwd="120.59.184.32" dyno=web.1 connect=1ms service=825ms status=500 bytes=11821

This is the return statement from my view.py , verify_api() :

 if valid :
             print 'True'
             return HttpResponse(json.dumps({'success': 'True',}), status = 200, content_type='application/json')
         else:
             return HttpResponse(json.dumps({'success': 'False'}), status = 400, content_type='application/json')

For debugging I tried printing out stuff as the computation is being done and what I observed from heroku logs was the computation stops in the middle of the process and sends internal server error 500 .

How can I avoid this internal server error and get a response from my verify_api() method inside my view.py.

Note: This request works fine in local development mode inside my machine with ./manage runserver. [I never get 500 response error in local development]

来源:https://stackoverflow.com/questions/30287967/internal-server-error-500-on-heroku-django-by-sending-an-ajax-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!