-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
53 lines (49 loc) · 2.16 KB
/
Copy pathapp.py
File metadata and controls
53 lines (49 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from flask import Flask, render_template, url_for, request, redirect
from punctuapp import PunctuApp
import os
app = Flask(__name__)
punct = PunctuApp()
@app.route('/', methods=['POST', 'GET'])
def index():
if request.method == 'POST' and not (os.path.exists('token.json')):
punct.login()
elif (os.path.exists('token.json')):
punct.login()
return redirect('/dashboard')
else:
return render_template('index.html')
@app.route('/dashboard', methods=['POST', 'GET'])
def dashboard():
if request.method == 'POST':
if request.form['logout'] == 'Log out':
punct.logout()
return redirect('/')
elif punct.calendar.time_diff() - 420 <= 180:
return redirect('/event_soon')
else:
print(punct.calendar.time_diff())
return render_template('dashboard.html',
event1_desc = punct.get_event()[1],
event1_loc = punct.get_event()[0],
event1_time = punct.get_realtime(),
email = 'This meeting could\'ve been an email' if punct.get_is_email() == 1 else ''
)
@app.route('/event_soon', methods=['POST', 'GET'])
def event_soon():
if request.method == 'POST':
if request.form['logout'] == 'Log out':
punct.logout()
return redirect('/')
elif punct.calendar.time_diff() - 420 > 180:
return redirect('/dashboard')
else:
time_to_dest = punct.distMatrix.get_traffic_time(punct.next_event[0])['rows'][0]['elements'][0]['duration']['value'] / 60
return render_template('event_soon.html',
event1_desc = punct.get_event()[1],
event1_loc = punct.get_event()[0],
event1_time = punct.get_realtime(),
event1_travel = abs(punct.calendar.time_diff() - 420 - time_to_dest),
email = 'This meeting could\'ve been an email' if punct.get_is_email() == 1 else ''
)
if __name__ == '__main__':
app.run(debug=True)