| from flask import Flask, request, jsonify |
| import json |
| import os |
| from flask_cors import CORS |
|
|
| app = Flask(__name__) |
| CORS(app) |
|
|
| DATA_FILE = "profiles.json" |
|
|
| role_questions = { |
| "Startup Mentor": [ |
| "Your one line description." |
| "What are your areas of expertise?", |
| "Mention any past mentorships or accelerator affiliations.", |
| "How would you describe your mentorship style?", |
| "What kind of startups are you looking to mentor? (Seperate with commas)" |
| ], |
| "Ideator": [ |
| "Which college/year are you from?", |
| "Your one line description.", |
| "Briefly describe the idea you're exploring.", |
| "What's the current stage of your project?", |
| "Any early feedback or traction you've seen?", |
| "What kind of collaborators are you looking for? (seperate with commas)", |
| ], |
| "Founder": [ |
| "What's the name of your startup and domain?", |
| "What problem are you solving?", |
| "What inspired you to work on this?", |
| "What traction/milestones have you achieved?", |
| "What are the biggest challenges you're facing?", |
| "Mention any notable achievements or recognitions.", |
| "Whom are you looking for? (Seperate with commas)" |
| ], |
| "Skilled Contributor": [ |
| "Your college and year?", |
| "What's your current role or position?", |
| "List your core technical skills.", |
| "Mention 1–2 past projects or contributions.", |
| "Any viral moments or recognitions?", |
| "What kind of opportunities are you looking for?", |
| "Skill sets you can contribute to startups? (Seperate with commas)" |
| ] |
| } |
|
|
| @app.route("/questions", methods=["GET"]) |
| def get_questions(): |
| role = request.args.get("role") |
| questions = role_questions.get(role, []) |
| return jsonify({"questions": questions}) |
|
|
| @app.route("/save", methods=["POST"]) |
| def save_profile(): |
| data = request.json |
| |
| try: |
| if os.path.exists(DATA_FILE): |
| with open(DATA_FILE, "r") as f: |
| try: |
| profiles = json.load(f) |
| if not isinstance(profiles, list): |
| profiles = [] |
| except json.JSONDecodeError: |
| profiles = [] |
| else: |
| profiles = [] |
| |
| profiles.append(data) |
| |
| with open(DATA_FILE, "w") as f: |
| json.dump(profiles, f, indent=2) |
| |
| return jsonify({"message": "Saved successfully"}) |
| except Exception as e: |
| return jsonify({"error": str(e)}), 500 |
|
|
| @app.route("/profiles", methods=["GET"]) |
| def get_profiles(): |
| """Optional endpoint to retrieve all profiles""" |
| try: |
| if os.path.exists(DATA_FILE): |
| with open(DATA_FILE, "r") as f: |
| profiles = json.load(f) |
| return jsonify({"profiles": profiles}) |
| else: |
| return jsonify({"profiles": []}) |
| except Exception as e: |
| return jsonify({"error": str(e)}), 500 |
|
|
| if __name__ == "__main__": |
| app.run(debug=True, port=5000) |