Download backend/test_backend.py from algorembrant/MT5report-parser: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/algorembrant/MT5report-parser/resolve/main/backend/test_backend.py
- Command line
-
hf download hf://algorembrant/MT5report-parser/backend/test_backend.py
-
curl -L -o test_backend.py https://huggingface.co/algorembrant/MT5report-parser/resolve/main/backend/test_backend.py
1.13 kB
| import requests | |
| import os | |
| from pathlib import Path | |
| BASE_URL = "http://localhost:8000" | |
| def test_backend(): | |
| print(f"Testing backend at {BASE_URL}...") | |
| # 1. Health Check | |
| try: | |
| r = requests.get(f"{BASE_URL}/") | |
| print(f"Root: {r.status_code} - {r.json()}") | |
| except Exception as e: | |
| print(f"Failed to connect: {e}") | |
| return | |
| # 2. Upload | |
| dummy_file = "test_upload.xlsx" | |
| # Create empty dummy file | |
| with open(dummy_file, "wb") as f: | |
| f.write(b"dummy excel content") | |
| files = {'file': (dummy_file, open(dummy_file, 'rb'))} | |
| try: | |
| r = requests.post(f"{BASE_URL}/upload", files=files) | |
| print(f"Upload: {r.status_code} - {r.json()}") | |
| except Exception as e: | |
| print(f"Upload failed: {e}") | |
| finally: | |
| os.remove(dummy_file) | |
| # 3. List Processed | |
| try: | |
| r = requests.get(f"{BASE_URL}/processed") | |
| print(f"Processed: {r.status_code} - {r.json()}") | |
| except Exception as e: | |
| print(f"List processed failed: {e}") | |
| if __name__ == "__main__": | |
| test_backend() | |