使用python的接口测试环境搭建及使用
2021-05-06 04:27
标签:python3 stat 下载 wan and content route org lang 使用python的接口测试环境搭建及使用 标签:python3 stat 下载 wan and content route org lang 原文地址:https://www.cnblogs.com/LinxiHuang/p/13191086.htmlusage:
>>> import requests
>>> r = requests.get(‘https://www.python.org‘)
>>> r.status_code
200
>>> ‘Python is a programming language‘ in r.content
True
... or POST:
>>> payload = dict(key1=‘value1‘, key2=‘value2‘)
>>> r = requests.post(‘https://httpbin.org/post‘, data=payload)
>>> print(r.text)
{
...
"form": {
"key2": "value2",
"key1": "value1"
},
...
}#coding=utf-8
import requests
import json
from flask import Flask
app = Flask(__name__)
@app.route("/")
def logine():
data = json.dump(
{
‘username‘: "aa",
‘password‘: "111111"
}
)
return data
if __name__ == "__main__":
app.run()