1
0
mirror of https://github.com/LibreTranslate/LibreTranslate.git synced 2025-11-23 22:04:43 +02:00
Files
LibreTranslate/scripts/healthcheck.py
shrewd-laidback palace e30572255c healthcheck.py: Fail on non 200 status
This way the health check will also fail on 500 and similar
2025-07-05 13:17:53 +02:00

16 lines
417 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
)
response.raise_for_status() # if server unavailable then requests with raise exception and healthcheck will fail