forked from FreeJules/AirBnB_clone_v4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
4-number_route.py
executable file
·48 lines (38 loc) · 1.04 KB
/
4-number_route.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
#!/usr/bin/python3
"""
Sript that starts a Flask web application
"""
from flask import Flask
app = Flask(__name__)
@app.route('/', strict_slashes=False)
def hello_hbn():
"""
function to return Hello HBNB!
"""
return "Hello HBNB!"
@app.route('/hbnb', strict_slashes=False)
def hbnb():
"""
function to return HBNB
"""
return "HBNB"
@app.route('/c/<text>', strict_slashes=False)
def text_var(text):
"""
function to display text variable passed in
"""
return "C {}".format(text.replace("_", " "))
@app.route('/python/<text>', strict_slashes=False)
def text_var_python(text="is cool"):
"""
function to display text variable, with default "is cool"
"""
return "Python {}".format(text.replace("_", " "))
@app.route('/number/<int:n>', strict_slashes=False)
def var_num(n):
"""
function to display a variable, but only if an int
"""
return "{} is a number".format(n)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)