Spaces:
Sleeping
Sleeping
Update main.py
Browse files
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
|
| 236 |
except Exception as e:
|
| 237 |
-
return jsonify({"message": f"Failed to
|
| 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()
|