Skip to content

Commit 6417d05

Browse files
committed
add CH6
1 parent a69e598 commit 6417d05

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
- [CH5 Python[4]](https://hackmd.io/@macs1207/HJF56PlnS#/)
2424
1. [DOM解析](https://hackmd.io/@macs1207/HJF56PlnS#/2)
2525
2. [API](https://hackmd.io/@macs1207/HJF56PlnS#/3)
26+
- [CH6 Python[5]](https://hackmd.io/@macs1207/BkU_hwqnS#)
27+
1. [Flask](https://hackmd.io/@macs1207/BkU_hwqnS#/2)
2628

2729

2830
# 作者

ch6/flask_sample.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from flask import Flask, request
2+
3+
app = Flask(__name__)
4+
5+
@app.route('/', methods=["GET", "POST"])
6+
def index():
7+
if request.method == "GET":
8+
data = request.args.get("data")
9+
return "GET, {}".format(data)
10+
elif request.method == "POST":
11+
data = request.values['data']
12+
return "POST, {}".format(data)
13+
14+
if __name__ == '__main__':
15+
app.run(port=8080)

ch6/post.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import requests
2+
3+
rs = requests.post("http://127.0.0.1:8080/", data={"name": "IAMPOST"})
4+
print(rs.text)

0 commit comments

Comments
 (0)