Spaces:
Sleeping
Sleeping
Update app/routes.py
Browse files- app/routes.py +6 -6
app/routes.py
CHANGED
@@ -53,9 +53,9 @@ def process_image():
|
|
53 |
logger.warning("No file uploaded")
|
54 |
return jsonify({"error": "No file uploaded"}), 400
|
55 |
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
|
60 |
file = request.files['file']
|
61 |
if file.filename == '':
|
@@ -69,8 +69,8 @@ def process_image():
|
|
69 |
"supported_formats": list(ALLOWED_EXTENSIONS)
|
70 |
}), 400
|
71 |
|
72 |
-
|
73 |
-
|
74 |
|
75 |
file_bytes = file.read()
|
76 |
file_stream = io.BytesIO(file_bytes)
|
@@ -83,7 +83,7 @@ def process_image():
|
|
83 |
if allergy_analyzer is None:
|
84 |
init_allergy_analyzer(current_app._get_current_object())
|
85 |
|
86 |
-
analysis_results = allergy_analyzer.analyze_text(extracted_text)
|
87 |
|
88 |
response = {
|
89 |
"success": True,
|
|
|
53 |
logger.warning("No file uploaded")
|
54 |
return jsonify({"error": "No file uploaded"}), 400
|
55 |
|
56 |
+
if 'allergens' not in request.form:
|
57 |
+
logger.warning("Allergens not specified")
|
58 |
+
return jsonify({"error": "Allergens not specified"}), 400
|
59 |
|
60 |
file = request.files['file']
|
61 |
if file.filename == '':
|
|
|
69 |
"supported_formats": list(ALLOWED_EXTENSIONS)
|
70 |
}), 400
|
71 |
|
72 |
+
user_allergens = [a.strip().lower() for a in request.form['allergens'].split(',')]
|
73 |
+
logger.info(f"Processing image for allergens: {user_allergens}")
|
74 |
|
75 |
file_bytes = file.read()
|
76 |
file_stream = io.BytesIO(file_bytes)
|
|
|
83 |
if allergy_analyzer is None:
|
84 |
init_allergy_analyzer(current_app._get_current_object())
|
85 |
|
86 |
+
analysis_results = allergy_analyzer.analyze_text(extracted_text,user_allergens)
|
87 |
|
88 |
response = {
|
89 |
"success": True,
|