Spaces:
Running
Running
Update app/api/routes.py
Browse files- app/api/routes.py +10 -3
app/api/routes.py
CHANGED
|
@@ -9,9 +9,16 @@ api_bp = Blueprint('api', __name__, url_prefix='/api')
|
|
| 9 |
|
| 10 |
@api_bp.route('/form-data', methods=['GET'])
|
| 11 |
def get_form_data():
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
@api_bp.route('/recommend', methods=['POST'])
|
| 17 |
async def recommend_recipes(): # Make this function async
|
|
|
|
| 9 |
|
| 10 |
@api_bp.route('/form-data', methods=['GET'])
|
| 11 |
def get_form_data():
|
| 12 |
+
# Use os.path.join to create a platform-independent path
|
| 13 |
+
file_path = os.path.join(os.getcwd(), 'form_data.json')
|
| 14 |
+
try:
|
| 15 |
+
with open(file_path, 'r') as file:
|
| 16 |
+
data = file.read()
|
| 17 |
+
return data
|
| 18 |
+
except FileNotFoundError:
|
| 19 |
+
return jsonify({"error": f"File not found at {file_path}"}), 404
|
| 20 |
+
except Exception as e:
|
| 21 |
+
return jsonify({"error": str(e)}), 500
|
| 22 |
|
| 23 |
@api_bp.route('/recommend', methods=['POST'])
|
| 24 |
async def recommend_recipes(): # Make this function async
|