2022-02-14 11:13:33 +03:00
|
|
|
from app import app
|
2020-08-27 10:07:46 +03:00
|
|
|
from flask import request
|
|
|
|
|
|
|
|
|
2022-02-05 08:56:33 +03:00
|
|
|
@app.route("/multipart-form-data", methods=["POST"])
|
|
|
|
def multipart_form_data():
|
|
|
|
assert request.form["key1"] == "value1"
|
|
|
|
assert "Expect" not in request.headers
|
2020-08-27 10:07:46 +03:00
|
|
|
|
2022-02-05 08:56:33 +03:00
|
|
|
upload1 = request.files["upload1"]
|
|
|
|
assert upload1.filename == "data.txt"
|
|
|
|
assert upload1.content_type == "text/plain"
|
|
|
|
assert upload1.read() == b"Hello World!"
|
2020-08-27 10:07:46 +03:00
|
|
|
|
2022-02-05 08:56:33 +03:00
|
|
|
upload2 = request.files["upload2"]
|
|
|
|
assert upload2.filename == "data.html"
|
|
|
|
assert upload2.content_type == "text/html"
|
|
|
|
assert upload2.read() == b"<div>Hello <b>World</b>!</div>"
|
2020-08-27 10:07:46 +03:00
|
|
|
|
2022-02-05 08:56:33 +03:00
|
|
|
upload3 = request.files["upload3"]
|
|
|
|
assert upload3.filename == "data.txt"
|
|
|
|
assert upload3.content_type == "text/html"
|
|
|
|
assert upload3.read() == b"Hello World!"
|
2020-08-27 10:07:46 +03:00
|
|
|
|
2022-02-05 08:56:33 +03:00
|
|
|
return ""
|