Update routes.py

support form data for flask 3
This commit is contained in:
Sefik Ilkin Serengil 2024-12-19 11:19:59 +00:00 committed by GitHub
parent b4ffec1a2f
commit 4fe4ba289e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -72,7 +72,9 @@ def extract_image_from_request(img_key: str) -> Union[str, np.ndarray]:
@blueprint.route("/represent", methods=["POST"])
def represent():
input_args = request.get_json() or request.form.to_dict()
input_args = (request.is_json and request.get_json()) or (
request.form and request.form.to_dict()
)
try:
img = extract_image_from_request("img")
@ -96,7 +98,9 @@ def represent():
@blueprint.route("/verify", methods=["POST"])
def verify():
input_args = request.get_json() or request.form.to_dict()
input_args = (request.is_json and request.get_json()) or (
request.form and request.form.to_dict()
)
try:
img1 = extract_image_from_request("img1")
@ -126,7 +130,9 @@ def verify():
@blueprint.route("/analyze", methods=["POST"])
def analyze():
input_args = request.get_json() or request.form.to_dict()
input_args = (request.is_json and request.get_json()) or (
request.form and request.form.to_dict()
)
try:
img = extract_image_from_request("img")