qecho / test.py
valent-p's picture
feat: Introduce 'burn after reading' functionality for message retrieval and a new CLI tool.
31c8c9e
Raw History Blame Contribute Delete
1.34 kB
import requests
# Replace with your Hugging Face Space URL
API_URL = "https://valent-p-qecho.hf.space"
def send_activity(group, password, message):
payload = {
"group_name": group,
"password": password,
"data": message
}
r = requests.post(f"{API_URL}/store", json=payload)
print(f"Send Status: {r.status_code} - {r.json()}")
def get_activity(group, password):
payload = {
"group_name": group,
"password": password
}
r = requests.post(f"{API_URL}/retrieve", json=payload)
if r.status_code == 200:
msgs = r.json()['messages']
print(f"\n--- Messages for {group} ---")
for m in msgs:
print(f"[{m['timestamp']}] {m['content']}")
else:
print("Error:", r.text)
# --- SCENARIO: COLLISION AVOIDANCE ---
print("1. Alice sending to 'ProjectX' with pass 'alice123'...")
send_activity("ProjectX", "alice123", "Alice's Secret Report")
print("\n2. Bob sending to 'ProjectX' with pass 'bob456'...")
send_activity("ProjectX", "bob456", "Bob's Malware Logs")
print("\n3. Alice retrieves 'ProjectX' with 'alice123'...")
# She should ONLY see "Alice's Secret Report"
get_activity("ProjectX", "alice123")
print("\n4. Bob retrieves 'ProjectX' with 'bob456'...")
# He should ONLY see "Bob's Malware Logs"
get_activity("ProjectX", "bob456")