import sys import os import json import requests def main(): img_path = sys.argv[1] if len(sys.argv) > 1 else 'test.jpg' url = 'http://127.0.0.1:5000/api/predict' if not os.path.exists(img_path): print(f"File not found: {img_path}") return try: with open(img_path, 'rb') as f: files = {'file': f} resp = requests.post(url, files=files) print(f'Status code: {resp.status_code}') try: print(json.dumps(resp.json(), indent=2)) except Exception: print(resp.text) except requests.exceptions.ConnectionError as e: print('Connection error: Is the Flask server running?') print(e) if __name__ == '__main__': main()