mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-12-19 17:01:36 +03:00
28 lines
849 B
Python
28 lines
849 B
Python
# curl -v -F key1=value1 -F upload1=@tests/hello.txt -Fupload2=@tests/hello.html http://localhost:8000/multipart-form-data
|
|
from tests import app
|
|
from flask import request
|
|
|
|
@app.route("/multipart-form-data", methods=['POST'])
|
|
def multipart_form_data():
|
|
|
|
assert request.form['key1'] == 'value1'
|
|
|
|
upload1 = request.files['upload1']
|
|
assert upload1.filename == 'hello.txt'
|
|
assert upload1.content_type == 'text/plain'
|
|
assert upload1.read() == b'Hello World!'
|
|
|
|
upload2 = request.files['upload2']
|
|
assert upload2.filename == 'hello.html'
|
|
assert upload2.content_type == 'text/html'
|
|
assert upload2.read() == b'Hello <b>World</b>!'
|
|
|
|
upload3 = request.files['upload3']
|
|
assert upload3.filename == 'hello.txt'
|
|
assert upload3.content_type == 'text/html'
|
|
assert upload3.read() == b'Hello World!'
|
|
|
|
return ''
|
|
|
|
|