Spaces:
Paused

File size: 751 Bytes
46efd9c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import httpx
import asyncio
import os
from dotenv import load_dotenv

load_dotenv()

BASE_URL = os.getenv("API_BASE_URL", "http://127.0.0.1:8000")

async def sync_dynamics():
    print(f"Starting sync from {BASE_URL}/api/dynamics/sync ...")
    async with httpx.AsyncClient(timeout=60.0) as client:
        try:
            response = await client.post(f"{BASE_URL}/api/dynamics/sync")
            if response.status_code == 200:
                print(f"Sync successful: {response.json().get('message')}")
            else:
                print(f"Sync failed with status {response.status_code}: {response.text}")
        except Exception as e:
            print(f"Error during sync: {e}")

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