Forums

Flask App works on local host but because buggy on PA

I've asked this same question on StackOverflow to get more visibility so I can figure out my issue. I figured I'd ask here too since it might be an issue with how PA is configured differently than my own localhost.

http://stackoverflow.com/questions/15455056/python-flask-app-works-on-localhost-but-because-buggy-when-put-on-production-py

I am writing a simple hockey app to keep track of scoring chances. This is written in Python/Flask + sqlite3 of which I am all new to. Part of the app generates a game report of the game to say who was on the ice when and who has chances for and against and at what state of the game. For some reason the script acts buggy and doesn't calculate correctly when places on my PythonAnywhere.com host.

You can see the script in action at http://sareon.pythonanywhere.com/gamereport/20234 (it does take a few seconds to load because it uses BeautifulSoup to parse a few webpages).

This is what the same script with the same data generates on my local machine: http://imgur.com/wefVJtN

Clearly there are some discrepencies between the two.

The code for reference is on github at https://github.com/sareon/hockey-scoring-chances/ App.py calls gamereport() which calls scrape.py in the case of these two tables (2 and 3) uses the function getGamePlayerStats().

No errors are being called as far as I can see and nothing is generating errors on my error log or access log. But I just cannot figure out why the two are generating completely different answers.

The problems I can tell in production are:

  1. Both tables generate the same list of players including both home and away players. Table 2 should only list the homePlayers from gameSummaryHome and table 3 should only list the awayPlayers from gameSummaryAway. Locally it does this but not on the host. I am not sure how they are being combined.

  2. On the host it is not returning any values for the players names and time on ice from scrape.getGamePlayerStats() and I can't figure out why. it is able to open and parse the other page for table 1 but nothing seems to be happening for table 2.

So those are the two big issues and they might be related, I am not sure. But the problem is that I have no idea how to debug it on the server to figure out where things are breaking. At least locally I could print to the terminal and see what the output is when running the page.

Any input would be appreciated. Thanks!

Solved, the problem came from two different issues - one causing the other. There was an error in the parsing of the page that returned nothing, but for some reason worked on my local machine.

Funny, you solved it by the time I got done reading through and understanding the problem...☺

Welcome to PA!!

Excellent, glad you worked it out @sareon!

Perhaps the difference is that we have a different version of one of the libraries you use, eg. BeautifulSoup?