mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-11-28 19:01:02 +00:00
Merge pull request #207 from dingedi/feature/disable-web-ui
Add --disable-web-ui
This commit is contained in:
commit
15dcfa12c6
4 changed files with 36 additions and 21 deletions
|
@ -135,7 +135,7 @@ docker-compose up -d --build
|
||||||
## Arguments
|
## Arguments
|
||||||
|
|
||||||
| Argument | Description | Default | Env. name |
|
| Argument | Description | Default | Env. name |
|
||||||
| ------------- | ------------------------------ | -------------------- | ---------------------- |
|
|-----------------------------|-------------------------------------------------------------------------------------------------------------| -------------------- |------------------------------|
|
||||||
| --host | Set host to bind the server to | `127.0.0.1` | LT_HOST |
|
| --host | Set host to bind the server to | `127.0.0.1` | LT_HOST |
|
||||||
| --port | Set port to bind the server to | `5000` | LT_PORT |
|
| --port | Set port to bind the server to | `5000` | LT_PORT |
|
||||||
| --char-limit | Set character limit | `No limit` | LT_CHAR_LIMIT |
|
| --char-limit | Set character limit | `No limit` | LT_CHAR_LIMIT |
|
||||||
|
@ -152,6 +152,7 @@ docker-compose up -d --build
|
||||||
| --load-only | Set available languages | `all from argostranslate` | LT_LOAD_ONLY |
|
| --load-only | Set available languages | `all from argostranslate` | LT_LOAD_ONLY |
|
||||||
| --suggestions | Allow user suggestions | `false` | LT_SUGGESTIONS |
|
| --suggestions | Allow user suggestions | `false` | LT_SUGGESTIONS |
|
||||||
| --disable-files-translation | Disable files translation | `false` | LT_DISABLE_FILES_TRANSLATION |
|
| --disable-files-translation | Disable files translation | `false` | LT_DISABLE_FILES_TRANSLATION |
|
||||||
|
| --disable-web-ui | Disable web ui | `false` | LT_DISABLE_WEB_UI |
|
||||||
|
|
||||||
Note that each argument has an equivalent env. variable that can be used instead. The env. variables overwrite the default values but have lower priority than the command aguments. They are particularly useful if used with Docker. Their name is the upper-snake case of the command arguments' ones, with a `LT` prefix.
|
Note that each argument has an equivalent env. variable that can be used instead. The env. variables overwrite the default values but have lower priority than the command aguments. They are particularly useful if used with Docker. Their name is the upper-snake case of the command arguments' ones, with a `LT` prefix.
|
||||||
|
|
||||||
|
|
|
@ -209,6 +209,9 @@ def create_app(args):
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
@limiter.exempt
|
@limiter.exempt
|
||||||
def index():
|
def index():
|
||||||
|
if args.disable_web_ui:
|
||||||
|
abort(404)
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"index.html",
|
"index.html",
|
||||||
gaId=args.ga_id,
|
gaId=args.ga_id,
|
||||||
|
@ -221,6 +224,9 @@ def create_app(args):
|
||||||
@app.route("/javascript-licenses", methods=["GET"])
|
@app.route("/javascript-licenses", methods=["GET"])
|
||||||
@limiter.exempt
|
@limiter.exempt
|
||||||
def javascript_licenses():
|
def javascript_licenses():
|
||||||
|
if args.disable_web_ui:
|
||||||
|
abort(404)
|
||||||
|
|
||||||
return render_template("javascript-licenses.html")
|
return render_template("javascript-licenses.html")
|
||||||
|
|
||||||
@app.route("/languages", methods=["GET", "POST"])
|
@app.route("/languages", methods=["GET", "POST"])
|
||||||
|
|
|
@ -120,7 +120,12 @@ _default_options_objects = [
|
||||||
'name': 'DISABLE_FILES_TRANSLATION',
|
'name': 'DISABLE_FILES_TRANSLATION',
|
||||||
'default_value': False,
|
'default_value': False,
|
||||||
'value_type': 'bool'
|
'value_type': 'bool'
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
'name': 'DISABLE_WEB_UI',
|
||||||
|
'default_value': False,
|
||||||
|
'value_type': 'bool'
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -108,6 +108,9 @@ def main():
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--disable-files-translation", default=DEFARGS['DISABLE_FILES_TRANSLATION'], action="store_true", help="Disable files translation"
|
"--disable-files-translation", default=DEFARGS['DISABLE_FILES_TRANSLATION'], action="store_true", help="Disable files translation"
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--disable-web-ui", default=DEFARGS['DISABLE_WEB_UI'], action="store_true", help="Disable web ui"
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
app = create_app(args)
|
app = create_app(args)
|
||||||
|
|
Loading…
Reference in a new issue