Swapnil-101 commited on
Commit
8137971
·
verified ·
1 Parent(s): 1bc047d

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +17 -5
main.py CHANGED
@@ -224,17 +224,29 @@ def verify_mentor():
224
  if not mentors:
225
  return jsonify({"message": "No mentors to verify"}), 404
226
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  with open("mentor.txt", "a") as mentor_file:
228
- mentors_data = mentor_file.read()
229
- print(mentors_data)
230
  for mentor_details in mentors:
231
- mentor_file.write(mentor_details)
232
 
233
  open("temp_mentor.txt", "w").close()
234
 
235
- return jsonify({"message": "Mentors verified and added successfully"}), 200
236
  except Exception as e:
237
- return jsonify({"message": f"Failed to verify mentors: {str(e)}"}), 500
238
 
239
  @app.route('/ai_mentor', methods=['POST'])
240
  @jwt_required()
 
224
  if not mentors:
225
  return jsonify({"message": "No mentors to verify"}), 404
226
 
227
+ return jsonify({"mentors": mentors}), 200
228
+ except Exception as e:
229
+ return jsonify({"message": f"Failed to retrieve mentors: {str(e)}"}), 500
230
+
231
+ @app.route('/add_verified_mentors', methods=['POST'])
232
+ def add_verified_mentors():
233
+ try:
234
+ data = request.get_json()
235
+
236
+ if 'mentors' not in data:
237
+ return jsonify({"message": "Mentors data not found in request"}), 400
238
+
239
+ mentors = data['mentors']
240
+
241
  with open("mentor.txt", "a") as mentor_file:
 
 
242
  for mentor_details in mentors:
243
+ mentor_file.write(mentor_details + '\n')
244
 
245
  open("temp_mentor.txt", "w").close()
246
 
247
+ return jsonify({"message": "Mentors added successfully"}), 200
248
  except Exception as e:
249
+ return jsonify({"message": f"Failed to add mentors: {str(e)}"}), 500
250
 
251
  @app.route('/ai_mentor', methods=['POST'])
252
  @jwt_required()