Boka73's picture
Deploy Gradio app
6d57c45 verified
raw
history blame contribute delete
776 Bytes
import os
import urllib.request
import urllib.error
repo_id = "Boka73/Tender-data-automation"
token = os.environ.get("HF_TOKEN")
for endpoint in [
f"https://huggingface.co/api/spaces/{repo_id}/runtime",
f"https://huggingface.co/api/spaces/{repo_id}/logs",
]:
print("---", endpoint)
req = urllib.request.Request(endpoint)
if token:
req.add_header("Authorization", f"Bearer {token}")
try:
with urllib.request.urlopen(req, timeout=30) as response:
text = response.read().decode("utf-8", errors="replace")
print(response.status)
print(text[-4000:])
except urllib.error.HTTPError as exc:
text = exc.read().decode("utf-8", errors="replace")
print(exc.code)
print(text[-4000:])