malteos commited on
Commit
918191f
·
unverified ·
1 Parent(s): a11b9f4
Files changed (3) hide show
  1. Dockerfile +1 -3
  2. app.py +12 -8
  3. 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
- RUN hf-mount status
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
- row = con.execute("""
18
- SELECT crawl_id
19
- FROM sqlite_scan(?, 'crawls')
20
- ORDER BY crawl_date DESC
21
- LIMIT 1
22
- """, [db_path]).fetchone()
 
23
 
24
- latest_crawl_id = row[0]
25
 
26
- return {"Hello": "World!", "latest_crawl": latest_crawl, "exists": os.path.exists(db_path)}
 
 
 
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