jonathanagustin commited on
Commit
d8953ff
·
verified ·
1 Parent(s): f0f9a82

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -166,13 +166,15 @@ def get_rows(
166
  limit: int = Query(20, ge=1, le=100)
167
  ):
168
  """Get paginated rows from a config."""
 
169
  try:
170
  sql = f"SELECT * FROM data LIMIT {limit} OFFSET {offset}"
171
  rows = query_parquet(config, sql)
172
 
173
  # Get total count
174
  count_sql = "SELECT COUNT(*) as cnt FROM data"
175
- total = query_parquet(config, count_sql)[0]["cnt"]
 
176
 
177
  return {
178
  "rows": rows,
@@ -180,8 +182,10 @@ def get_rows(
180
  "offset": offset,
181
  "limit": limit
182
  }
 
 
183
  except Exception as e:
184
- raise HTTPException(status_code=500, detail=str(e))
185
 
186
 
187
  @app.get("/search/{config}")
 
166
  limit: int = Query(20, ge=1, le=100)
167
  ):
168
  """Get paginated rows from a config."""
169
+ import traceback
170
  try:
171
  sql = f"SELECT * FROM data LIMIT {limit} OFFSET {offset}"
172
  rows = query_parquet(config, sql)
173
 
174
  # Get total count
175
  count_sql = "SELECT COUNT(*) as cnt FROM data"
176
+ count_result = query_parquet(config, count_sql)
177
+ total = count_result[0]["cnt"] if count_result else 0
178
 
179
  return {
180
  "rows": rows,
 
182
  "offset": offset,
183
  "limit": limit
184
  }
185
+ except HTTPException:
186
+ raise
187
  except Exception as e:
188
+ return {"error": str(e), "traceback": traceback.format_exc()}
189
 
190
 
191
  @app.get("/search/{config}")