Spaces:
Running

MeloonTop / backend /sync_dynamics.py
isold's picture
code fromate
d52aa6b
Raw History Blame Contribute Delete
792 Bytes
import asyncio
import os
import httpx
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())