django http接口测试

curl

#get
curl http://address:port/url?args
#post
curl http://address:port/url -d "param1=value1&param2=value2"
#上传文件
curl http://address:port/url -F "[email protected]"

python

import requests


FILE_NAME = '111.jpg'
FILE_PATH = FILE_NAME

url = "http://address:port/url"

with open(FILE_PATH, 'rb') as fb:
    files = {'file': (FILE_NAME, fb, 'application/jpeg')}
    response = requests.post(url, files=files)
    print(response.text)

猜你喜欢

转载自blog.csdn.net/weixin_33127753/article/details/83095027