Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -111,6 +111,34 @@ def search():
|
|
| 111 |
|
| 112 |
return jsonify(data), resp.status_code
|
| 113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
@app.route('/<path:path>')
|
| 115 |
def static_files(path):
|
| 116 |
return send_from_directory('.', path)
|
|
|
|
| 111 |
|
| 112 |
return jsonify(data), resp.status_code
|
| 113 |
|
| 114 |
+
@app.route('/debug')
|
| 115 |
+
def debug():
|
| 116 |
+
info = {
|
| 117 |
+
"TAVILY_KEY_set": bool(TAVILY_KEY),
|
| 118 |
+
"HF_TOKEN_set": bool(HF_TOKEN),
|
| 119 |
+
"HF_DATASET": HF_DATASET or "NOT SET",
|
| 120 |
+
}
|
| 121 |
+
if HF_TOKEN and HF_DATASET:
|
| 122 |
+
try:
|
| 123 |
+
cache = hf_get_cache()
|
| 124 |
+
info["hf_read"] = "OK"
|
| 125 |
+
info["cache_keys_count"] = len(cache)
|
| 126 |
+
info["cache_keys"] = list(cache.keys())[:20]
|
| 127 |
+
except Exception as e:
|
| 128 |
+
info["hf_read"] = f"ERROR: {e}"
|
| 129 |
+
try:
|
| 130 |
+
r = requests.get(
|
| 131 |
+
f"https://huggingface.co/api/datasets/{HF_DATASET}/tree/main",
|
| 132 |
+
headers=hf_headers(), timeout=10
|
| 133 |
+
)
|
| 134 |
+
info["hf_tree_status"] = r.status_code
|
| 135 |
+
info["hf_files"] = [f.get("path") for f in r.json()] if r.ok else r.text[:200]
|
| 136 |
+
except Exception as e:
|
| 137 |
+
info["hf_tree"] = f"ERROR: {e}"
|
| 138 |
+
else:
|
| 139 |
+
info["hf_status"] = "HF_TOKEN or HF_DATASET not set — cache disabled"
|
| 140 |
+
return jsonify(info)
|
| 141 |
+
|
| 142 |
@app.route('/<path:path>')
|
| 143 |
def static_files(path):
|
| 144 |
return send_from_directory('.', path)
|