-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
47 lines (36 loc) · 998 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
39
40
41
42
43
44
45
46
# ---- Flask Hello World ---- #
# import the Flask class from the flask module
from flask import Flask
# create the application object
app = Flask(__name__)
# user decorators to link the function to a url
@app.route("/")
@app.route("/hello")
# define the view using a function, which returns a string
def hello_world():
return "Hello, World!"
# dynamic route
@app.route('/test/<search_query>')
def search(search_query):
return search_query
@app.route('/integer/<int:value>')
def int_type(value):
print value + 1
return 'correct'
@app.route('/float/<float:value>')
def float_type(value):
print value + 1
return 'correct'
@app.route('/path/<path:value>')
def path_type(value):
print value
return 'correct'
@app.route('/name/<name>')
def index(name):
if name.lower() == 'dave':
return 'Hello, {}'.format(name), 200
else:
return 'Not Found', 404
# start the development server using the run() method
if __name__ == '__main__':
app.run()