File size: 1,895 Bytes
09281fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python3
"""
Quick Test for app2.py Server
"""

import requests
import time

BASE_URL = "https://0468c638cef7.ngrok-free.app"

def test_server():
    print("πŸ§ͺ Quick Server Test")
    print("=" * 40)
    
    # Test 1: Health Check
    print("1. Testing health endpoint...")
    try:
        response = requests.get(f"{BASE_URL}/api/health", timeout=10)
        print(f"   Status: {response.status_code}")
        if response.status_code == 200:
            print("   βœ… Server is running!")
        else:
            print(f"   ❌ Server error: {response.text}")
    except Exception as e:
        print(f"   ❌ Connection failed: {e}")
        print("   πŸ’‘ Make sure to run: python app2.py")
        return False
    
    # Test 2: Simple Query
    print("\n2. Testing simple query...")
    try:
        headers = {
            "Content-Type": "application/json",
            "Authorization": "Bearer test_key_123"
        }
        payload = {
            "questions": ["What is the grace period for premium payment?"]
        }
        
        response = requests.post(f"{BASE_URL}/hackrx/run", 
                               json=payload, headers=headers, timeout=30)
        print(f"   Status: {response.status_code}")
        if response.status_code == 200:
            print("   βœ… Query processed successfully!")
            result = response.json()
            print(f"   Answer: {result.get('answers', [''])[0][:100]}...")
        else:
            print(f"   ❌ Query failed: {response.text}")
    except Exception as e:
        print(f"   ❌ Query error: {e}")
    
    print("\n" + "=" * 40)
    print("πŸ“‹ NEXT STEPS:")
    print("1. Make sure app2.py is running: python app2.py")
    print("2. Keep the server running in a separate terminal")
    print("3. Test your Postman requests")
    print("=" * 40)

if __name__ == "__main__":
    test_server()