Spaces:
Sleeping
Sleeping
File size: 769 Bytes
b67af4a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import json
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
from scripts.hf_tools import HFSpaceInfoTool
def main():
tool = HFSpaceInfoTool()
repo_id = "gradio/calculator" # simple public demo space
result_json_str = tool.forward(repo_id=repo_id)
try:
data = json.loads(result_json_str)
print(json.dumps(data, indent=2, ensure_ascii=False))
except Exception:
# Fallback: encode to UTF-8 to avoid Windows cp1252 issues
try:
print(result_json_str.encode("utf-8", errors="replace").decode("utf-8", errors="replace"))
except Exception:
print("<unprintable> due to encoding error")
if __name__ == "__main__":
main()
|