-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path4-number_route.py
54 lines (41 loc) · 1.41 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
49
50
51
52
53
54
#!/usr/bin/python3
"""0x04. AirBnB clone - Web framework, task 4. Is it a number?
"""
from flask import Flask
from os import environ
app = Flask(__name__)
environ['FLASK_ENV'] = 'development'
@app.route('/', strict_slashes=False)
def index():
"""Test method to output simple greeting on localhost port 5000,
`/` path.
"""
return 'Hello HBNB!'
@app.route('/hbnb', strict_slashes=False)
def hbnb():
"""Test method to output simple message on localhost port 5000,
`/hbnb` path.
"""
return 'HBNB'
@app.route('/c/<text>', strict_slashes=False)
def c_subpath(text):
"""Test method to output simple message on localhost port 5000,
`/c/` path, converting subpaths into message text.
"""
return ' '.join(['C', text.replace('_', ' ')])
@app.route('/python/', strict_slashes=False)
@app.route('/python/<text>', strict_slashes=False)
def python_subpath(text='is cool'):
"""Test method to output simple message on localhost port 5000,
`/python/` path, converting subpaths into message text, with
a default string.
"""
return ' '.join(['Python', text.replace('_', ' ')])
@app.route('/number/<int:n>', strict_slashes=False)
def number(n):
"""Test method to output simple message on localhost port 5000,
`/number/` path, only if subpath is an integer.
"""
return '{} is a number'.format(n)
if __name__ == '__main__':
app.run(host='0.0.0.0', port='5000')