forked from Obihai/AirBnB_clone_v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
6-number_odd_or_even.py
executable file
·64 lines (47 loc) · 1.53 KB
/
6-number_odd_or_even.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
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/python3
"""
Starts a Flask web application.
"""
from flask import Flask
from flask import render_template
app = Flask(__name__)
app.jinja_env.trim_blocks = True
app.jinja_env.lstrip_blocks = True
@app.route("/", strict_slashes=False)
def hello_hbnb():
"""renders 'Hello HBNB!'"""
return "Hello HBNB!"
@app.route("/hbnb", strict_slashes=False)
def hbnb():
"""returns 'HBNB'"""
return "HBNB"
@app.route("/c/<text>", strict_slashes=False)
def c(text):
"""Displays 'C' followed by the value of <text>
"""
text = text.replace("_", " ")
return "C {}".format(text)
@app.route("/python", strict_slashes=False)
@app.route("/python/<text>", strict_slashes=False)
def python(text="is cool"):
"""Displays 'Python' followed by the value of <text>
"""
text = text.replace("_", " ")
return "Python {}".format(text)
@app.route("/number/<int:n>", strict_slashes=False)
def number(n):
"""Displays 'n is a number' only if <n> is an integer."""
return "{} is a number".format(n)
@app.route("/number_template/<int:n>", strict_slashes=False)
def number_template(n):
"""Displays an HTML page only if <n> is an integer.
"""
return render_template("5-number.html", n=n)
@app.route("/number_odd_or_even/<int:n>", strict_slashes=False)
def number_odd_or_even(n):
"""Displays an HTML page only if <n> is an integer.
shows whether <n> is odd or even in the body.
"""
return render_template("6-number_odd_or_even.html", n=n)
if __name__ == "__main__":
app.run(host="0.0.0.0")