Forums

havent changed my app and it randomly doesn't work now?

I had my web app here for a long time and checked it periodically. A few weeks ago I noticed it was down and today I tried getting it to work but cant. I even reuploaded the entire project and tested in localhost that it worked fine with the exact same code, I am getting this error

2014-01-22 03:09:46,770 :Starting new HTTP connection (1): proxy.server
2014-01-22 03:09:46,992 :Exception on / [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1687, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1360, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1358, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1344, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/droidBehavior/mysite/routes.py", line 41, in index
    pic = j['data']['children'][rand]['data']['url']
KeyError: 'data'

the weird thing is when I change the code at the error it doesn't reflect that change and the error log is always the same even if I delete the row pic=j.... it still says error at pic = j

That sounds like you're not reloading your web app after you're making a change.

Wow no I did that five hundred times.

The error is the same but it's still a new error. Like I said I never touched the code and the site broke but in local it works and it's the same exact code.

Ah. Sorry. I just noticed the "Starting new HTTP connection" line. It looks like you may be trying to access an external site and we block most of those for free accounts.

hm its just accessing imgur, its using reddit to find the urls. It was working before, but how would I know if I am being blocked. The error is definitely the json but like I said when I deleted the row and clicked reload(500 times) it still said error at the same line which was extremely weird. Deleting the web app and reuploading same error. Json works fine on localhost.

OK, so I see that there are 2 problems that you're having: 1. Reload doesn't seem to reload your web app - That's really strange. Are you seeing the reload happening in your server log? Are you trying to hit the reloading web app before it's been shut down? 2. You're not getting the json you expect from reddit - What are you getting back from reddit? If there's no data entry in the json you're getting back, perhaps you're getting an error message.

actually reloading works I was wrong on that

I found out I am getting an error in the json but I have no idea why. When I test the SAME url on localhost AND manually by visiting reddit on chrome, I get a json response from both ways. Only on pythonanywhere the json fails, but it is the exact same request that works when I manually type it in the search bar or in localhost.

I know I get an error because I did print j['error'] and it returned an error {u'error': 429}

edit: I googled and it said its because of my user agent, I am not sure how to set up a user agent on flask will try to do it