SamiKoen commited on
Commit
cc64afc
·
1 Parent(s): d8b5f76

Debug endpoint: /debug-warehouse - cache durumunu disaridan kontrol icin

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py CHANGED
@@ -40,6 +40,24 @@ async def health():
40
  }
41
 
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  def apply_pronunciation_fixes(text: str) -> str:
44
  """Telaffuz duzeltmeleri — model bazi yer isimlerini Ingilizce gibi okumasin diye
45
  metni modele iletmeden once kucuk yazim degisiklikleri uygulanir."""
 
40
  }
41
 
42
 
43
+ @app.get("/debug-warehouse")
44
+ async def debug_warehouse():
45
+ """get_cached_warehouse_xml() durumunu kontrol et — Cloudflare/Trek PHP debug icin."""
46
+ import re
47
+ from collections import Counter
48
+ from smart_warehouse_with_price import get_cached_warehouse_xml
49
+ try:
50
+ xml = get_cached_warehouse_xml()
51
+ except Exception as e:
52
+ return {"error": str(e)}
53
+ if not xml:
54
+ return {"xml": None, "warehouses": {}, "size": 0}
55
+ whs = re.findall(r"<!\[CDATA\[([^\]]+)\]\]></Name>", xml)
56
+ counts = dict(Counter(whs))
57
+ head = xml[:300] if len(xml) > 300 else xml
58
+ return {"size": len(xml), "warehouses": counts, "head": head}
59
+
60
+
61
  def apply_pronunciation_fixes(text: str) -> str:
62
  """Telaffuz duzeltmeleri — model bazi yer isimlerini Ingilizce gibi okumasin diye
63
  metni modele iletmeden once kucuk yazim degisiklikleri uygulanir."""