ranilmukesh commited on
Commit
dfe09a2
·
1 Parent(s): f5fb29c

feat: update static file serving and paths for styles and scripts

Browse files
Files changed (4) hide show
  1. index.html +2 -2
  2. main.py +8 -2
  3. routing_engine.py +20 -0
  4. script.js +2 -2
index.html CHANGED
@@ -12,7 +12,7 @@
12
  <link
13
  href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Space+Grotesk:wght@400;500;600;700&display=swap"
14
  rel="stylesheet">
15
- <link rel="stylesheet" href="/static/styles.css">
16
  </head>
17
 
18
  <body>
@@ -608,7 +608,7 @@
608
  Demo Data
609
  </button>
610
 
611
- <script src="/static/script.js"></script>
612
  </body>
613
 
614
  </html>
 
12
  <link
13
  href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Space+Grotesk:wght@400;500;600;700&display=swap"
14
  rel="stylesheet">
15
+ <link rel="stylesheet" href="styles.css">
16
  </head>
17
 
18
  <body>
 
608
  Demo Data
609
  </button>
610
 
611
+ <script src="script.js"></script>
612
  </body>
613
 
614
  </html>
main.py CHANGED
@@ -475,8 +475,14 @@ async def chat_m(req: dict):
475
  return {"response": resp}
476
 
477
  # --- Static File Serving for Frontend ---
478
- # 1. Mount styles.css and script.js so they can be loaded by index.html automatically
479
- app.mount("/static", StaticFiles(directory="."), name="static")
 
 
 
 
 
 
480
 
481
  # 2. Serve index.html at root
482
  @app.get("/")
 
475
  return {"response": resp}
476
 
477
  # --- Static File Serving for Frontend ---
478
+ # 1. Provide styles.css and script.js directly at root level
479
+ @app.get("/styles.css")
480
+ async def read_styles():
481
+ return FileResponse("styles.css")
482
+
483
+ @app.get("/script.js")
484
+ async def read_js():
485
+ return FileResponse("script.js")
486
 
487
  # 2. Serve index.html at root
488
  @app.get("/")
routing_engine.py CHANGED
@@ -67,6 +67,26 @@ class RoutingEngine:
67
  missing_skills = self.get_gap(best_job, user_skills)
68
  return best_job, missing_skills
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  def get_subgraph_figure_base64(self, center_node, user_skills, depth=1):
71
  try:
72
  if center_node not in self.G.nodes: return None
 
67
  missing_skills = self.get_gap(best_job, user_skills)
68
  return best_job, missing_skills
69
 
70
+ def get_career_transition_path(self, current_job, target_job):
71
+ """Finds the shortest upskilling path between two roles via shared skills."""
72
+ if current_job not in self.G.nodes or target_job not in self.G.nodes:
73
+ return None
74
+
75
+ try:
76
+ # NetworkX finds the shortest path alternating: Job -> Skill -> Job
77
+ path = nx.shortest_path(self.G, source=current_job, target=target_job)
78
+
79
+ skills_to_learn = [node for node in path if node in self.all_unique_skills]
80
+ stepping_stones = [node for node in path if node in self.all_jobs and node not in (current_job, target_job)]
81
+
82
+ return {
83
+ "path": path,
84
+ "skills_to_learn": skills_to_learn,
85
+ "stepping_stones": stepping_stones
86
+ }
87
+ except Exception:
88
+ return None
89
+
90
  def get_subgraph_figure_base64(self, center_node, user_skills, depth=1):
91
  try:
92
  if center_node not in self.G.nodes: return None
script.js CHANGED
@@ -6,8 +6,8 @@
6
  */
7
 
8
  // API Configuration
9
- // Use current host for API calls instead of hardcoded localhost
10
- const API_BASE_URL = window.location.origin;
11
 
12
  // DOM Elements
13
  const elements = {
 
6
  */
7
 
8
  // API Configuration
9
+ // Use specific port 8000 for backend API calls
10
+ const API_BASE_URL = window.location.protocol + "//" + window.location.hostname + ":8000";
11
 
12
  // DOM Elements
13
  const elements = {