updates routines script and google certification handling
This commit is contained in:
parent
5e7080695d
commit
2ecb5a4b71
2
app.py
2
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)
|
||||
|
2
backend
2
backend
@ -1 +1 @@
|
||||
Subproject commit 8d546e37a890846313e62d1392a09956d109794a
|
||||
Subproject commit b5dbfd87defaaed87c73f321ac3087fe5a7c689b
|
@ -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.
|
||||
|
@ -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/<path:user>/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
|
||||
|
Loading…
Reference in New Issue
Block a user