Inayatgaming commited on
Commit
4831215
·
verified ·
1 Parent(s): edc4d4a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -36,9 +36,7 @@ def root():
36
 
37
  @app.get("/health")
38
  def health():
39
- return {
40
- "status": "ok"
41
- }
42
 
43
 
44
  @app.get("/lookup")
@@ -56,10 +54,13 @@ def lookup(
56
  detail="number is required"
57
  )
58
 
59
- con = duckdb.connect(
60
- DB_PATH,
61
- read_only=True
62
- )
 
 
 
63
 
64
  try:
65
  row = con.execute(
 
36
 
37
  @app.get("/health")
38
  def health():
39
+ return {"status": "ok"}
 
 
40
 
41
 
42
  @app.get("/lookup")
 
54
  detail="number is required"
55
  )
56
 
57
+ if not os.path.exists(DB_PATH):
58
+ raise HTTPException(
59
+ status_code=503,
60
+ detail="Authorized index is not installed"
61
+ )
62
+
63
+ con = duckdb.connect(DB_PATH, read_only=True)
64
 
65
  try:
66
  row = con.execute(