-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp3.py
More file actions
53 lines (43 loc) · 1.11 KB
/
Copy pathapp3.py
File metadata and controls
53 lines (43 loc) · 1.11 KB
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
# import packages
from flask import Flask
# create app
app = Flask(__name__)
# Define api
@app.route("/")
def index():
return "This is Home Page"
# develop api
@app.route("/hello")
def hello():
return "This is hello, world page"
# static
#develop api
@app.route("/Ajay")
def welcome():
return "Welcome Ajay, what is your order"
# static
#develop api
@app.route("/C B Shukla")
def greet():
return "Welcome C B Shulka ji, what is your plan for today"
# dynamic
# develop api
@app.route('/<name>')
def namaskara(name):
return f'welcome {name}. What would you like to order.'
# route param
@app.route('/post/<id>')
def show_post(id):
return f'Post ID is: {id}'
@app.route('/product/<name>')
def get_prodcut(name):
return 'Product is :' + name
@app.route('/sale/<transaction_id>')
def get_sale(transaction_id = 0):
return 'The trasaction is ' + str(transaction_id)
# multiple param
@app.route('/create/<first_name>/<last_name>')
def create(first_name=None, last_name=None):
return 'Hello ' + first_name + last_name
if __name__ == "__main__":
app.run(host="127.0.0.1", port=8083, debug=False)