1. 程式人生 > >django http介面測試

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)