This is the Python code that i am using:
@app.route("/getInformation", methods=['GET'])
def domain():
urlList = []
urlList.append("http://gbgfotboll.se/serier/?scr=table&ftid=57109")
urlList.append("http://127.0.0.1/")
urlList.append("http://gbgfotboll.se/serier/?scr=table&ftid=57108")
date = '2015-04-18'
# use this in real mode: currentDate = (time.strftime("%Y-%m-%d"))
homeScore = "0"
awayScore = "0"
homeTeam = ""
awayTeam = ""
time_xpath = XPath("td[1]/span/span//text()[2]")
team_xpath = XPath("td[2]/a/text()")
league_xpath = XPath("//*[@id='content-primary']/h1//text()")
for url in urlList:
test = 2
rows_xpath = XPath("//*[@id='content-primary']/table/tbody/tr[td[1]/span/span//text()='%s']" % (date))
html = lxml.html.parse(url)
divName = league_xpath(html)[0]
trash, divisionName = divName.rsplit("- ")
dict[divisionName] = {}
for id,row in enumerate(rows_xpath(html)):
#time = time_xpath(row)[0].strip() #use this in real code
time = "1%d"%test +":00" # remove this later
test += 1 #remove this
test %= 3 # remove this later
team = team_xpath(row)[0]
homeTeam, awayTeam = team.split(" - ")
hour, minute = time.split(":")
newTime = timeConvert(hour, minute)
dict[divisionName].update({ id :{"time":str(newTime),"tempTime": time ,"homeTeam":homeTeam,"homeScore":homeScore, "awayTeam":awayTeam, "awayScore":awayScore, "events" :[] }})
with open('gameFile.txt', 'wb') as handle:
pickle.dump(dict, handle)
return Response(mimetype='application/json') //Is there a better way?
//Note i am not trying to send anything back. i just noticed when running locally not writing this gave me an internal server error
When i go to http://localhost:5000/getInformation everything seems ok no error message is being shown and also it is doing what it should do. However when i put it on my server and run it there i receive an error message.
Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
If it is any help, i am using Heroku to upload the code to the server. I am also using Heroku's built in command foreman start to try the code locally.
EDIT1
Solved it thanks to the comments below by checking the logs. The error was:
IOError: Error reading file 'http://127.0.0.1/': failed to load external entity "http://127.0.0.1/"
Then it struck to me its a local address that i was running on my pc. Commenting out
urlList.append("http://127.0.0.1/")
Worked fine. Thank you