-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
executable file
·38 lines (31 loc) · 802 Bytes
/
app.py
File metadata and controls
executable file
·38 lines (31 loc) · 802 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
#!/usr/bin/env python
from flask import Flask, render_template, jsonify
from random import randint
app = Flask(__name__)
WAYS_TO_SAY_NO = [
'No.',
'Nope.',
'No. Thanks.',
'Not today.',
'Not this month.',
'Not ever.',
'Maybe. But No.',
'Never.'
]
@app.route('/')
def index():
index = randint(0, len(WAYS_TO_SAY_NO) - 1)
no = WAYS_TO_SAY_NO[index]
return render_template('index.html', nope=no)
@app.route('/api/nope')
def api_nope():
index = randint(0, len(WAYS_TO_SAY_NO) - 1)
nope = {'say:': WAYS_TO_SAY_NO[index]}
return jsonify(nope)
@app.route('/no')
def no():
index = randint(0, len(WAYS_TO_SAY_NO) - 1)
no = WAYS_TO_SAY_NO[index]
return render_template('no.html', no=no)
if __name__ == '__main__':
app.run(debug=True)