#!/usr/bin/env python3
"""
Quick test to check server response
"""

import requests
import time
import subprocess
import sys
import os

def test_server():
    """Test server responses"""
    
    print("🔍 Testing Server Responses")
    print("=" * 30)
    
    base_url = "http://127.0.0.1:8000"
    
    # Test pages
    pages = [
        "/utils/documents/",
        "/utils/notifications/", 
        "/utils/receipts/"
    ]
    
    for page in pages:
        try:
            url = base_url + page
            print(f"Testing: {url}")
            
            response = requests.get(url, timeout=5, allow_redirects=False)
            print(f"  Status: {response.status_code}")
            
            if response.status_code == 302:
                location = response.headers.get('Location', 'Unknown')
                print(f"  Redirects to: {location}")
            elif response.status_code == 200:
                print(f"  ✅ Success")
            else:
                print(f"  ❌ Error")
                
        except requests.exceptions.RequestException as e:
            print(f"  ❌ Connection error: {e}")
        
        print()

if __name__ == '__main__':
    print("Make sure Django server is running on http://127.0.0.1:8000")
    print("Run: python manage.py runserver")
    print()
    
    input("Press Enter when server is ready...")
    test_server()