-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
38 lines (27 loc) · 779 Bytes
/
app.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
import random
import pyjokes
from flask import Flask, render_template
from flask_bootstrap import Bootstrap
app = Flask(__name__)
Bootstrap(app)
def replace_double_quotes(text):
return text.replace('"', "'")
def laugh():
candidates = ["hm hm hm",
"ha ha",
"ha",
"ha ha ha",
"hahaha, hm hm hm, hm hm hm",
"hmm",
"ha, ha. heh, heh hou"]
return random.choice(candidates)
@app.route('/')
def hello_world():
joke = new_joke()
return render_template('index.html', joke=joke, laugh=laugh())
@app.route('/joke')
def new_joke():
joke = replace_double_quotes(pyjokes.get_joke())
return joke
if __name__ == '__main__':
app.run(debug=True)