When I run the app locally (at localhost:8080), it works as it should. When deployed on heroku, it often gives "NameError: 'APIservice' is not defined".
APIservice is the variable containing the google API object, per Google's documentation. It is build in the 'start' view:
@app.route('/start')
def start_teatime(): # Checks auth & builds calendar API (APIservice)
print('stat_teatime trigger')
global APIservice
if 'credentials' not in session:
return redirect('authorize')
# Load credentials from the session.
credentials = google.oauth2.credentials.Credentials(
**session['credentials'])
APIservice = googleapiclient.discovery.build(
API_SERVICE_NAME, API_VERSION, credentials=credentials)
return redirect(url_for('user_input'))
APIservice gets used in the next view ('user_input') and in different functions in the same .py file. Yet, Heroku says APIservice is not defined. Does anyone have an idea why this is happening?