MANOJSEQ commited on
Commit
84fb685
·
verified ·
1 Parent(s): 6d176a8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os, sys
2
+
3
+ # HF Spaces pass the port via PORT
4
+ PORT = os.environ.get("PORT", "7860")
5
+
6
+ # Limit models for faster boot + smaller disk use (tweak as you like)
7
+ os.environ.setdefault(
8
+ "LT_LOAD_ONLY",
9
+ "en,es,fr,de,pt,ru,ar,hi,ja,ko,zh"
10
+ )
11
+
12
+ # Start LibreTranslate and download/update models on first boot
13
+ args = [
14
+ "libretranslate",
15
+ "--host", "0.0.0.0",
16
+ "--port", str(PORT),
17
+ "--update-models"
18
+ ]
19
+
20
+ # Replace this Python process with the LT server (cleaner signals)
21
+ os.execvp(args[0], args)