garvitcpp commited on
Commit
34f9c2d
·
verified ·
1 Parent(s): 8ee4652

Update app/api/routes.py

Browse files
Files changed (1) hide show
  1. 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
- with open('form_data.json', 'r') as file:
26
- data = json.load(file)
27
- return jsonify(data)
 
 
 
 
 
 
 
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