Web2Py 应用程序 运行 在本地计算机上但不在 PythonAnywhere 上
Web2Py App running on local machine but not on PythonAnywhere
我刚刚在 Web2Py 中制作了一个应用程序,它在我的本地机器上运行良好。但是,当我将它部署到 PythonAnywhere 并尝试 运行 应用程序时,出现以下错误:
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
我不确定为什么会出现此错误,因为它可以在我的本地计算机上运行。我几乎在应用程序的每个页面中都收到此错误。这是我收到错误的一个函数:
def index():
"""Get parameters for current date to pass into url"""
day = time.strftime('%d')
month = time.strftime('%m')
year = time.strftime('%Y')
url = 'http://stats.nba.com/scores/#!/' + month + '/' + day + '/' + year
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36'}
"""Get results from response at NBA.com to obtain standings for Eastern and Western Conference"""
with requests.Session() as session:
session.headers = headers
session.get(url, headers=headers)
params = {
'DayOffset': '0',
'GameDate': month + '/' + day + '/' + year,
'LeagueID': '00'
}
response = session.get('http://stats.nba.com/stats/scoreboardV2?DayOffset=0&LeagueID=00&gameDate='+month+'%2F'+day+'%2F'+year, params=params)
results = response.json()
eastHeaders = results['resultSets'][4]['headers']
eastRows = results['resultSets'][4]['rowSet']
westHeaders = results['resultSets'][5]['headers']
westRows = results['resultSets'][5]['rowSet']
return dict(eastHeaders=eastHeaders,eastRows=eastRows,westHeaders=westHeaders,westRows=westRows)
我收到错误的具体行是:
results = response.json()
我刚刚在 Web2Py 中制作了一个应用程序,它在我的本地机器上运行良好。但是,当我将它部署到 PythonAnywhere 并尝试 运行 应用程序时,出现以下错误:
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
我不确定为什么会出现此错误,因为它可以在我的本地计算机上运行。我几乎在应用程序的每个页面中都收到此错误。这是我收到错误的一个函数:
def index():
"""Get parameters for current date to pass into url"""
day = time.strftime('%d')
month = time.strftime('%m')
year = time.strftime('%Y')
url = 'http://stats.nba.com/scores/#!/' + month + '/' + day + '/' + year
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36'}
"""Get results from response at NBA.com to obtain standings for Eastern and Western Conference"""
with requests.Session() as session:
session.headers = headers
session.get(url, headers=headers)
params = {
'DayOffset': '0',
'GameDate': month + '/' + day + '/' + year,
'LeagueID': '00'
}
response = session.get('http://stats.nba.com/stats/scoreboardV2?DayOffset=0&LeagueID=00&gameDate='+month+'%2F'+day+'%2F'+year, params=params)
results = response.json()
eastHeaders = results['resultSets'][4]['headers']
eastRows = results['resultSets'][4]['rowSet']
westHeaders = results['resultSets'][5]['headers']
westRows = results['resultSets'][5]['rowSet']
return dict(eastHeaders=eastHeaders,eastRows=eastRows,westHeaders=westHeaders,westRows=westRows)
我收到错误的具体行是:
results = response.json()