-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
35 lines (28 loc) · 801 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
# ---- Flask Hello World ---- #
# import the Flask class from the flask package
from flask import Flask
# create the application object
app = Flask(__name__)
# error handling
app.config['DEBUG'] = True
# use the decocorator pattern to
# link the view 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
# difference response types
@app.route("/name/<name>")
def index(name):
if name == 'Abbas':
return 'Hello, {}'.format(name)
else:
return 'Not Found', 404
# start the development server using the run() method
if __name__ == "__main__":
app.run()