-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
33 lines (26 loc) · 958 Bytes
/
Copy pathapp.py
File metadata and controls
33 lines (26 loc) · 958 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
# import the Flask class from the flask module
from flask import Flask, render_template, redirect, url_for, request, Markup
import sys
sys.path.append("..")
from start import analyze
# create the application object
app = Flask(__name__)
credentials = '../secret/client_secret.json'
# use decorators to link the function to a url
@app.route('/')
def home():
return render_template('main.html') # return a string
@app.route('/analytics')
def analytics():
info, user_id, success = analyze(credentials)
if not success:
sys.exit(0)
args = {"info_{0}".format(k) : Markup(v.replace('\n', "<br />")) for (k, v) in enumerate(info)}
ans = render_template('analytics.html', **args, user_id=user_id)
return ans # return a string
@app.route('/contacts')
def contacts():
return render_template('contacts.html') # render a template
# start the server with the 'run()' method
if __name__ == '__main__':
app.run(debug=False)