Spaces:
Runtime error
Runtime error
Download test_predict.py from moi-123/iA_DOCENTE: direct link, hf CLI and curl.
- Browser
- Download file 521 Bytes
-
https://huggingface.co/spaces/moi-123/iA_DOCENTE/resolve/main/test_predict.py
- Command line
-
hf download hf://spaces/moi-123/iA_DOCENTE/test_predict.py
-
curl -L -o test_predict.py https://huggingface.co/spaces/moi-123/iA_DOCENTE/resolve/main/test_predict.py
521 Bytes
| import os | |
| import requests | |
| PORT = int(os.environ.get('PORT', 7860)) | |
| HOST = os.environ.get('HOST', 'http://localhost') | |
| URL = f"{HOST}:{PORT}/run/predict" | |
| def test_predict(q="¿Hola? Prueba"): | |
| try: | |
| r = requests.post(URL, json={"data": [q]}, timeout=10) | |
| except Exception as e: | |
| print('Connection error:', e) | |
| return | |
| print('status', r.status_code) | |
| try: | |
| print('json', r.json()) | |
| except Exception: | |
| print('text', r.text) | |
| if __name__ == '__main__': | |
| test_predict() | |