ntdservices commited on
Commit
47106b3
·
verified ·
1 Parent(s): 49d4316

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -226,17 +226,21 @@ def api_sites():
226
 
227
  @app.post("/api/sites")
228
  def api_add_site(site: SiteIn):
 
 
229
  with db_lock:
230
  try:
231
  conn.execute(
232
  "INSERT OR IGNORE INTO sites(url, name) VALUES (?, ?)",
233
- (site.url, site.name.strip() or site.url)
234
  )
235
  conn.commit()
236
  except sqlite3.Error as e:
 
237
  raise HTTPException(400, f"DB error: {e}")
238
  return {"ok": True}
239
 
 
240
  @app.delete("/api/sites")
241
  def api_delete_site(url: str):
242
  with db_lock:
 
226
 
227
  @app.post("/api/sites")
228
  def api_add_site(site: SiteIn):
229
+ url_s = str(site.url) # <- cast from HttpUrl to str
230
+ name_s = (site.name or "").strip() or url_s
231
  with db_lock:
232
  try:
233
  conn.execute(
234
  "INSERT OR IGNORE INTO sites(url, name) VALUES (?, ?)",
235
+ (url_s, name_s)
236
  )
237
  conn.commit()
238
  except sqlite3.Error as e:
239
+ # bubble up the real DB message so the UI can show it
240
  raise HTTPException(400, f"DB error: {e}")
241
  return {"ok": True}
242
 
243
+
244
  @app.delete("/api/sites")
245
  def api_delete_site(url: str):
246
  with db_lock: