Spaces:
Running
Running
| import os | |
| import requests | |
| from dotenv import load_dotenv | |
| load_dotenv(override=True) | |
| def test_pushover(): | |
| """Test Pushover notification service""" | |
| token = os.getenv("PUSHOVER_TOKEN") | |
| user = os.getenv("PUSHOVER_USER") | |
| print("Testing Pushover Configuration...") | |
| print(f"PUSHOVER_TOKEN: {'β Found' if token else 'β Missing'}") | |
| print(f"PUSHOVER_USER: {'β Found' if user else 'β Missing'}") | |
| if not token or not user: | |
| print("\nβ Missing credentials. Please add PUSHOVER_TOKEN and PUSHOVER_USER to your .env file") | |
| return | |
| # Test message | |
| test_message = "π Test notification from digital twin app!" | |
| try: | |
| print(f"\nπ€ Sending test message: '{test_message}'") | |
| response = requests.post( | |
| "https://api.pushover.net/1/messages.json", | |
| data={ | |
| "token": token, | |
| "user": user, | |
| "message": test_message, | |
| }, | |
| timeout=10 | |
| ) | |
| print(f"Status Code: {response.status_code}") | |
| print(f"Response: {response.text}") | |
| if response.status_code == 200: | |
| print("\nβ SUCCESS! Check your phone/device for the Pushover notification") | |
| else: | |
| print(f"\nβ FAILED! Status code: {response.status_code}") | |
| print(f"Error details: {response.text}") | |
| except requests.exceptions.RequestException as e: | |
| print(f"\nβ Network/Request Error: {e}") | |
| except Exception as e: | |
| print(f"\nβ Unexpected Error: {e}") | |
| if __name__ == "__main__": | |
| test_pushover() | |