ChandimaPrabath commited on
Commit
dc7ceea
·
1 Parent(s): e8095e3
Files changed (1) hide show
  1. main.py +17 -2
main.py CHANGED
@@ -22,8 +22,8 @@ async def download_and_save_data(url: str) -> str:
22
  return tmp_file.name
23
 
24
  # URLs for the data
25
- films_url = f'{LOAD_BALANCER_URL}/api/get/movie/all'
26
- tv_series_url = f'{LOAD_BALANCER_URL}/api/get/series/all'
27
 
28
  async def update_data_and_initialize():
29
  global search_system
@@ -64,3 +64,18 @@ async def search(query: Query):
64
  results = search_system.search(query_str)
65
 
66
  return results
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  return tmp_file.name
23
 
24
  # URLs for the data
25
+ films_url = f'{LOAD_BALANCER_URL}/api/film/all'
26
+ tv_series_url = f'{LOAD_BALANCER_URL}/api/tv/all'
27
 
28
  async def update_data_and_initialize():
29
  global search_system
 
64
  results = search_system.search(query_str)
65
 
66
  return results
67
+
68
+ @app.get("/api/data")
69
+ async def get_data():
70
+ global search_system
71
+
72
+ async with search_system_lock:
73
+ if search_system is None:
74
+ raise HTTPException(status_code=503, detail="Search system is not initialized yet.")
75
+
76
+ data = {
77
+ "films": list(search_system.films.values()),
78
+ "tv_series": {k: v["original"] for k, v in search_system.tv_series.items()}
79
+ }
80
+
81
+ return data