-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
52 lines (43 loc) · 1.43 KB
/
run.py
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
from flask import Flask, render_template, request
import os
import unirest
app = Flask(__name__)
app.debug = True
def get(famID):
try:
response = unirest.get(os.environ['CLERK_URL'] + 'tour/' + famID)
return response.body
except TypeError:
return None
@app.route('/<fid>', methods=['GET','POST'])
def index(fid):
print "THIS IS A TEST"
#process submission
first = request.args.get('first')
second = request.args.get('second')
third = request.args.get('third')
if bool(first) or bool(second) or bool(third):
review = ''
if bool(first):
review += "How awesome was your tour guide?\n\n"
review += first + '\n\n'
if bool(second):
review += "Was there anything you would have liked to have heard about, but didn't?\n\n"
review += second + '\n\n'
if bool(third):
review += "Was there anything you could have done without?\n\n"
review += third
print review
params = {'review': review}
response = unirest.put(os.environ['CLERK_URL'], params=params)
print response.body
return "Submitted"
#serve form
try:
data = {'id': fid}
data['name'] = get(data['id'])['name']
return render_template('followup.html', data=data)
except TypeError:
return render_template('index.html', data=data)
if __name__ == '__main__':
app.run()