libre-translate/scripts/healthcheck.py

16 lines
389 B
Python
Raw Normal View History

import requests
import os
2023-07-09 12:29:11 +02:00
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