Spaces:
Running
Running
Update app/api/routes.py
Browse files- app/api/routes.py +10 -3
app/api/routes.py
CHANGED
|
@@ -22,9 +22,16 @@ def health_check():
|
|
| 22 |
|
| 23 |
@api_bp.route('/form-data', methods=['GET'])
|
| 24 |
def get_form_data():
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
@api_bp.route('/recommend', methods=['POST'])
|
| 30 |
async def recommend_recipes(): # Make this function async
|
|
|
|
| 22 |
|
| 23 |
@api_bp.route('/form-data', methods=['GET'])
|
| 24 |
def get_form_data():
|
| 25 |
+
# Use os.path.join to create a platform-independent path
|
| 26 |
+
file_path = os.path.join(os.getcwd(), 'form_data.json')
|
| 27 |
+
try:
|
| 28 |
+
with open(file_path, 'r') as file:
|
| 29 |
+
data = file.read()
|
| 30 |
+
return data
|
| 31 |
+
except FileNotFoundError:
|
| 32 |
+
return jsonify({"error": f"File not found at {file_path}"}), 404
|
| 33 |
+
except Exception as e:
|
| 34 |
+
return jsonify({"error": str(e)}), 500
|
| 35 |
|
| 36 |
@api_bp.route('/recommend', methods=['POST'])
|
| 37 |
async def recommend_recipes(): # Make this function async
|