lt-server / app.py
MANOJSEQ's picture
Create app.py
84fb685 verified
Raw
History Blame Contribute Delete
507 Bytes
import os, sys
# HF Spaces pass the port via PORT
PORT = os.environ.get("PORT", "7860")
# Limit models for faster boot + smaller disk use (tweak as you like)
os.environ.setdefault(
"LT_LOAD_ONLY",
"en,es,fr,de,pt,ru,ar,hi,ja,ko,zh"
)
# Start LibreTranslate and download/update models on first boot
args = [
"libretranslate",
"--host", "0.0.0.0",
"--port", str(PORT),
"--update-models"
]
# Replace this Python process with the LT server (cleaner signals)
os.execvp(args[0], args)