libre-translate/scripts/healthcheck.py
DL6ER 042bafac2c
Support LT_PORT in healtcheck script
Signed-off-by: DL6ER <dl6er@dl6er.de>
2025-06-13 21:16:07 +02:00

15 lines
389 B
Python

import requests
import os
port = os.environ.get('LT_PORT', '5000')
response = requests.post(
url=f'http://localhost:{port}/translate',
headers={'Content-Type': 'application/json'},
json={
'q': 'Hello World!',
'source': 'en',
'target': 'en'
},
timeout=60
)
# if server unavailable then requests with raise exception and healthcheck will fail