Spaces:
Sleeping
Sleeping
malteos commited on
start sh
Browse files- Dockerfile +1 -3
- app.py +12 -8
- start.sh +5 -0
Dockerfile
CHANGED
|
@@ -13,8 +13,6 @@ RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
|
| 13 |
|
| 14 |
COPY --chown=user . /app
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
| 19 |
|
| 20 |
|
|
|
|
| 13 |
|
| 14 |
COPY --chown=user . /app
|
| 15 |
|
| 16 |
+
CMD ["bash", "start.sh"]
|
|
|
|
|
|
|
| 17 |
|
| 18 |
|
app.py
CHANGED
|
@@ -14,14 +14,18 @@ def greet_json():
|
|
| 14 |
con = duckdb.connect()
|
| 15 |
con.execute("INSTALL sqlite; LOAD sqlite;")
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
| 23 |
|
| 24 |
-
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
| 27 |
|
|
|
|
| 14 |
con = duckdb.connect()
|
| 15 |
con.execute("INSTALL sqlite; LOAD sqlite;")
|
| 16 |
|
| 17 |
+
try:
|
| 18 |
+
row = con.execute("""
|
| 19 |
+
SELECT crawl_id
|
| 20 |
+
FROM sqlite_scan(?, 'crawls')
|
| 21 |
+
ORDER BY crawl_date DESC
|
| 22 |
+
LIMIT 1
|
| 23 |
+
""", [db_path]).fetchone()
|
| 24 |
|
| 25 |
+
latest_crawl_id = row[0]
|
| 26 |
|
| 27 |
+
except Exception:
|
| 28 |
+
latest_crawl_id = "n/a"
|
| 29 |
+
|
| 30 |
+
return {"Hello": "World!", "latest_crawl": latest_crawl_id, "exists": os.path.exists(db_path)}
|
| 31 |
|
start.sh
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
hf-mount status
|
| 4 |
+
|
| 5 |
+
uvicorn app:app --host 0.0.0.0 --port 7860
|