-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
46 lines (37 loc) · 1.31 KB
/
Copy pathapp.py
File metadata and controls
46 lines (37 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from flask import Flask, render_template, jsonify, request
import json
app = Flask(__name__)
# Load predefined roadmaps
with open('roadmaps.json') as f:
roadmaps = json.load(f)
@app.route('/')
def home():
return render_template('learning.html')
# Save Goal Route
@app.route('/save_goal', methods=['POST'])
def save_goal():
goal = request.json.get('goal')
if goal:
# Save goal in the database or session (for now, we just print it)
print(f"Goal saved: {goal}")
return jsonify({"message": "Goal saved!"}), 200
else:
return jsonify({"error": "No goal provided"}), 400
# Generate Roadmap Route
@app.route('/generate-roadmap', methods=['POST'])
def generate_roadmap():
data = request.json
skill = data.get('skill')
duration = data.get('duration')
# Check if the skill exists in the roadmap
if skill not in roadmaps:
return jsonify({"error": "Skill not found"}), 400
# Adjust topics based on duration
roadmap = roadmaps[skill]
if duration == "3 Months":
roadmap = {k: v[:4] for k, v in roadmap.items()} # Limit topics for 3 months
elif duration == "6 Months":
roadmap = {k: v[:6] for k, v in roadmap.items()} # More topics for 6 months
return jsonify(roadmap)
if __name__ == '__main__':
app.run(debug=True)