0

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]

yask
  • 3,918
  • 4
  • 20
  • 29
  • Can you check the error logs, and paste the stack trace here ? – karthikr May 17 '15 at 14:44
  • This is the only error I see from 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 – yask May 17 '15 at 16:04
  • These are the access logs. Not error logs – karthikr May 17 '15 at 16:09
  • karthikr is correct; once you find the error in the error_log file, it'll mostly likely become self evident. – FlipperPA May 17 '15 at 22:07
  • Can't find any error log – yask May 18 '15 at 13:17
  • Which python are you using on Heroku? Your print won't work on 3+ – Dariusz Aniszewski May 18 '15 at 13:49
  • I am using python 2.7. This application makes fine request in local development mode. Problem is internal server error when deployed to heroku. – yask May 19 '15 at 20:51

0 Answers0