-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
38 lines (28 loc) · 983 Bytes
/
app.py
File metadata and controls
38 lines (28 loc) · 983 Bytes
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
from flask import Flask, render_template, request, redirect, url_for
from Profilers import UserProfiler
import UI
app = Flask(__name__)
@app.context_processor
def utility_processor():
return dict(
get_color=UI.get_color,
get_tag=UI.get_tag
)
@app.route('/user/<user>', methods=['GET','POST'])
def user(user):
if request.method == 'GET':
try:
us = UserProfiler(user)
return render_template('index.html', user=user, reports=us.get_yearly_report_table())
except Exception:
return render_template('error.html')
return redirect(url_for('user',user=request.form['user']))
@app.route('/', methods=['GET','POST'])
def start():
if request.method == 'POST':
if request.form['user'] == '':
return render_template('error.html')
return redirect(url_for('user',user=request.form['user']))
return render_template('start.html')
if __name__ == '__main__':
app.run()