1. postman介绍与安装
2. postman发送get请求
import pymysql
from flask import Flask,request
# 这里是mysql的基本连接信息
conn = pymysql.connect(
host="192.168.1.116",
user="root",
password="123",
database="nydb1",
charset="utf8"
)
cursor = conn.cursor()
app = Flask(__name__)
@app.route("/")
def hello_world():
sel = "select * from school"
result = cursor.execute(sql)
# 得到查询后的真正的结果
r = cursor.fetchall()
print(r)
return str(r)
@app.route("/mypost",methods=["post"])
def my_post():
return "post request"
@app.route("/mypost1",methods=["post"])
def my_post1():
# 表单数据类型
username =request.form["username"]
sex = request.form["sex"]
print(username)
print(sex)
return "post request" + username + "::" + sex
@app.route("/mypost1",methods=["post"])
def my_post2():
# json数据类型
request_data =request.get_json()
sex = request.form["sex"]
print(request_data)
print(request_data["user"])
return "post request" + str(request_data)
@app.route("/mypost",methods=["post"])
def my_post():
return "post request"
@app.route("/mypost1",methods=["post"])
def my_post1():
# 表单数据类型
username =request.form["username"]
sex = request.form["sex"]
print(username)
print(sex)
return "post request" + username + "::" + sex
@app.route("/mypost1",methods=["post"])
def my_post2():
# json数据类型
request_data =request.get_json()
sex = request.form["sex"]
print(request_data)
print(request_data["user"])
return "post request" + str(request_data)
if __name__ == "__main__":
app.run()
3. postman发送post请求
import pymysql
from flask import Flask,request
# 这里是mysql的基本连接信息
conn = pymysql.connect(
host="192.168.1.116",
user="root",
password="123",
database="nydb1",
charset="utf8"
)
cursor = conn.cursor()
app = Flask(__name__)
@app.route("/")
def hello_world():
sel = "select * from school"
result = cursor.execute(sql)
# 得到查询后的真正的结果
r = cursor.fetchall()
print(r)
return str(r)
@app.route("/mypost",methods=["post"])
def my_post():
return "post request"
@app.route("/mypost1",methods=["post"])
def my_post1():
# 表单数据类型
username =request.form["username"]
sex = request.form["sex"]
print(username)
print(sex)
return "post request" + username + "::" + sex
@app.route("/mypost1",methods=["post"])
def my_post2():
# json数据类型
request_data =request.get_json()
sex = request.form["sex"]
print(request_data)
print(request_data["user"])
return "post request" + str(request_data)
@app.route("/mypost",methods=["post"])
def my_post():
return "post request"
@app.route("/mypost1",methods=["post"])
def my_post1():
# 表单数据类型
username =request.form["username"]
sex = request.form["sex"]
print(username)
print(sex)
return "post request" + username + "::" + sex
@app.route("/mypost2",methods=["post"])
def my_post2():
# json数据类型
request_data =request.get_json()
sex = request.form["sex"]
print(request_data)
print(request_data["user"])
return "post request" + str(request_data)
if __name__ == "__main__":
app.run()
- 并在python里打印出