Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import os
|
| 2 |
-
import
|
| 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:
|
| 15 |
if not os.path.exists(EXTRACTED_JSON):
|
| 16 |
-
print("⏳ Extracting JSON
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
else:
|
| 21 |
-
print("❌
|
| 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():
|