gopallikehack commited on
Commit
59fea3b
·
verified ·
1 Parent(s): 7dbd92a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import os
2
- import zipfile
3
  import json
4
  from fastapi import FastAPI, Query
5
 
@@ -11,14 +11,20 @@ EXTRACTED_JSON = "/data/users_data.json"
11
  @app.on_event("startup")
12
  async def startup():
13
  if os.path.exists(FILE_PATH):
14
- print(f"✅ Found: HitekAll.zip")
15
  if not os.path.exists(EXTRACTED_JSON):
16
- print("⏳ Extracting JSON (this may take time)...")
17
- with zipfile.ZipFile(FILE_PATH, 'r') as zf:
18
- zf.extractall("/data/")
19
- print("✅ Extraction complete")
 
 
 
 
 
 
20
  else:
21
- print("❌ HitekAll.zip not found")
22
 
23
  @app.get("/")
24
  async def root():
 
1
  import os
2
+ import subprocess
3
  import json
4
  from fastapi import FastAPI, Query
5
 
 
11
  @app.on_event("startup")
12
  async def startup():
13
  if os.path.exists(FILE_PATH):
14
+ print(f"✅ Found: {FILE_PATH}")
15
  if not os.path.exists(EXTRACTED_JSON):
16
+ print("⏳ Extracting JSON using 7z...")
17
+ result = subprocess.run(
18
+ ["7z", "x", FILE_PATH, "-o/data/", "-y"],
19
+ capture_output=True,
20
+ text=True
21
+ )
22
+ if result.returncode == 0:
23
+ print("✅ Extraction complete")
24
+ else:
25
+ print(f"❌ Extraction failed: {result.stderr}")
26
  else:
27
+ print("❌ File not found")
28
 
29
  @app.get("/")
30
  async def root():