Download scripts/test_cors.py from Mohansree/bsure-api: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/spaces/Mohansree/bsure-api/resolve/main/scripts/test_cors.py
- Command line
-
hf download hf://spaces/Mohansree/bsure-api/scripts/test_cors.py
-
curl -L -o test_cors.py https://huggingface.co/spaces/Mohansree/bsure-api/resolve/main/scripts/test_cors.py
1.03 kB
| import requests | |
| try: | |
| print("Testing CORS preflight/headers...") | |
| response = requests.options( | |
| "http://localhost:8000/auth/register", | |
| headers={ | |
| "Origin": "http://localhost:3000", | |
| "Access-Control-Request-Method": "POST", | |
| "Access-Control-Request-Headers": "content-type" | |
| } | |
| ) | |
| print(f"OPTIONS Status: {response.status_code}") | |
| print(f"Access-Control-Allow-Origin: {response.headers.get('access-control-allow-origin')}") | |
| print(f"Access-Control-Allow-Methods: {response.headers.get('access-control-allow-methods')}") | |
| print("\nTesting POST request...") | |
| response = requests.post( | |
| "http://localhost:8000/auth/login", | |
| json={"email": "test@example.com", "password": "password123"}, | |
| headers={"Origin": "http://localhost:3000"} | |
| ) | |
| print(f"POST Status: {response.status_code}") | |
| print(f"Access-Control-Allow-Origin: {response.headers.get('access-control-allow-origin')}") | |
| except Exception as e: | |
| print(f"Error: {e}") | |