import requests from requests.auth import HTTPBasicAuth # Configuration user = "admin" password = "DonCucarach0?" ip_address = "100.100.112.48" port = "5984" url = f"http://{ip_address}:{port}/" print(f"--- CouchDB Debug Tool ---") print(f"Target: {url}") try: # 1. Test Network Connectivity (No Auth) print("\n1. Testing basic connectivity...") resp = requests.get(url, timeout=5) print(f" Success! Server responded: {resp.json().get('couchdb')}") except Exception as e: print(f" Network Failed: {e}") try: # 2. Test Authentication print("\n2. Testing Authentication (Basic Auth)...") resp = requests.get(url + "_session", auth=HTTPBasicAuth(user, password), timeout=5) if resp.status_code == 200: print(f" ✅ Auth Success! Session info: {resp.json().get('userCtx')}") else: print(f" ❌ Auth Failed (Status {resp.status_code}): {resp.text}") except Exception as e: print(f" Request Error: {e}") try: # 3. List Databases (Authenticated) print("\n3. Listing Databases...") resp = requests.get(url + "_all_dbs", auth=HTTPBasicAuth(user, password), timeout=5) if resp.status_code == 200: print(f" ✅ Found Databases: {resp.json()}") else: print(f" ❌ Failed to list DBs: {resp.text}") except Exception as e: print(f" Request Error: {e}")