File size: 1,021 Bytes
6f5bf7c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import httpx
import asyncio

BASE_URL = "http://localhost:8000"


async def check_keys():
    async with httpx.AsyncClient() as client:
        # Try 'test'
        print("Testing access_key=test...")
        res = await client.get(f"{BASE_URL}/current?access_key=test&query=New York")
        print(f"Status for 'test': {res.status_code}")
        if res.status_code == 200:
            print("WARNING: 'test' key still works!")
        else:
            print("SUCCESS: 'test' key rejected.")

        # Try the real key
        real_key = "b55a6ab9aec1ab156c0b46f0a9ef93dd"
        print(f"\nTesting access_key={real_key}...")
        res = await client.get(
            f"{BASE_URL}/current?access_key={real_key}&query=New York"
        )
        print(f"Status for real key: {res.status_code}")
        if res.status_code == 200:
            print("SUCCESS: Real key works.")
        else:
            print(f"FAILURE: Real key rejected. Body: {res.text}")


if __name__ == "__main__":
    asyncio.run(check_keys())