forked from shibing624/python-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01.http_method.py
More file actions
46 lines (30 loc) · 739 Bytes
/
01.http_method.py
File metadata and controls
46 lines (30 loc) · 739 Bytes
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
# -*- coding: utf-8 -*-
"""
@author:XuMing([email protected])
@description:
"""
from flask import Flask, request
app = Flask(__name__)
@app.route('/')
def index():
return 'Home page'
@app.route('/hello')
def hello():
return '<H1>app server</H1>'
@app.route('/user/<username>')
def show_user_name(username):
return 'Hey baby %s' % username
@app.route('/post/<int:id>')
def show_id(id):
return 'Show ID %d' % id
@app.route('/method')
def method():
return "Method use: %s" % request.method
@app.route('/choose', methods=['POST', 'GET'])
def choose():
if request.method == 'POST':
return 'You use POST'
else:
return 'YOU use GET'
if __name__ == "__main__":
app.run(debug=True)