diff --git a/app.py b/app.py index 98d357f..81a55a7 100644 --- a/app.py +++ b/app.py @@ -7,4 +7,4 @@ from backend import routine if __name__ == "__main__": context = ('certificate/xip.io.crt', 'certificate/xip.io.key')#certificate and key files # app.run('0.0.0.0', 8084, ssl_context='adhoc', debug=True) - app.run(host='0.0.0.0', port=8084) + app.run(host='0.0.0.0', port=8084, debug=True) diff --git a/backend b/backend index 8d546e3..b5dbfd8 160000 --- a/backend +++ b/backend @@ -1 +1 @@ -Subproject commit 8d546e37a890846313e62d1392a09956d109794a +Subproject commit b5dbfd87defaaed87c73f321ac3087fe5a7c689b diff --git a/server/googleHandler.py b/server/googleHandler.py index ae18493..c0a8915 100644 --- a/server/googleHandler.py +++ b/server/googleHandler.py @@ -119,7 +119,6 @@ def getCalendarJson(): # Load credentials from the session. credentials = google.oauth2.credentials.Credentials( **flask.session['credentials']) - todaysCal = caltojson.generateJsonFromCalendarEntries(credentials) with open('./userinfo/' + current_user.id + '/calendarevents.json', 'w') as outfile: json.dump(todaysCal, outfile) @@ -132,19 +131,20 @@ def updateCalendars(): return flask.redirect('login/google') # Load credentials from the session. - credentials = google.oauth2.credentials.Credentials( - **flask.session['credentials']) + # credentials = google.oauth2.credentials.Credentials( + # **flask.session['credentials']) + # a = flask.session['credentials'] + # print(a, flush=True) + # print(current_user.getGoogleCredentials(), flush=True) - + credentials = google.oauth2.credentials.Credentials(**current_user.getGoogleCredentials()) calendars = caltojson.getCalendarList(credentials) - for calendar in calendars: if dbCalendar.getCalendar(dbCalendar, current_user.id, calendar.calendarId) == None: dbCalendar.create(dbCalendar, current_user.id, calendar.calendarId, calendar.summary, calendar.color) print("updated Calendars") - # Save credentials back to session in case access token was refreshed. # ACTION ITEM: In a production app, you likely want to save these # credentials in a persistent database instead. diff --git a/server/routes.py b/server/routes.py index fe354b0..f403391 100644 --- a/server/routes.py +++ b/server/routes.py @@ -76,6 +76,14 @@ def register(): return redirect(url_for('emaillogin')) return render_template('register.html', title='Register', form=form) +@app.route("/test") +def testAPI(): + if current_user.is_authenticated: + google.updateCalendars() + return redirect('/account') + + + @app.route("/login/google") def googlelogin(): authorization_url = google.login() @@ -128,8 +136,8 @@ def credentials_to_dict(credentials): @app.route("/userinfo//calendarevents.json") def downloader(user): - print(user) - path = "userinfo/" + user + path = "/home/calendarwatch/userinfo/" + user + "/" + print(path, flush=True) return flask.send_from_directory(path, "calendarevents.json") # POST