Alfred/tempo/dona/archive/test_ally.py
2025-11-11 13:38:25 +01:00

29 lines
798 B
Python

import requests
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
url_ally = "https://192.168.1.12:8000/mic"
def ally(texte):
try:
if not texte:
return ""
payload = {"texto": texte}
headers = {"Content-Type": "application/json"}
# response = requests.post(url_ally, json=payload, headers=headers)
response = requests.post(
"https://192.168.1.12:8000/mic",
data=payload, # ⚠️ pas json=payload
verify=False # ⚠️ équivaut à -k dans curl
)
if response.status_code == 200:
data = response.json()
return data.get("ora", "")
else:
return ""
except Exception:
return ""
print(ally("bonjour"))