mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-11-16 10:08:23 +02:00
Fix bool False parameters with wsgi
This commit is contained in:
parent
279b55daaf
commit
a9440a8c5c
@ -12,7 +12,7 @@ def on_starting(server):
|
||||
proc_name = server.cfg.default_proc_name
|
||||
kwargs = {}
|
||||
if proc_name.startswith("wsgi:app"):
|
||||
str_args = re.sub('wsgi:app\s*\(\s*(.*)\s*\)', '\\1', proc_name).strip().split(",")
|
||||
str_args = re.sub(r'wsgi:app\s*\(\s*(.*)\s*\)', '\\1', proc_name).strip().split(",")
|
||||
for a in str_args:
|
||||
if "=" in a:
|
||||
k,v = a.split("=")
|
||||
@ -21,12 +21,15 @@ def on_starting(server):
|
||||
|
||||
if v.lower() in ["true", "false"]:
|
||||
v = v.lower() == "true"
|
||||
if not v:
|
||||
continue
|
||||
elif v[0] == '"':
|
||||
v = v[1:-1]
|
||||
kwargs[k] = v
|
||||
|
||||
from libretranslate.main import get_args
|
||||
sys.argv = ['--wsgi']
|
||||
|
||||
for k in kwargs:
|
||||
ck = k.replace("_", "-")
|
||||
if isinstance(kwargs[k], bool) and kwargs[k]:
|
||||
|
6
wsgi.py
6
wsgi.py
@ -4,10 +4,12 @@ from libretranslate import main
|
||||
def app(*args, **kwargs):
|
||||
import sys
|
||||
sys.argv = ['--wsgi']
|
||||
|
||||
for k in kwargs:
|
||||
ck = k.replace("_", "-")
|
||||
if isinstance(kwargs[k], bool) and kwargs[k]:
|
||||
sys.argv.append("--" + ck)
|
||||
if isinstance(kwargs[k], bool):
|
||||
if kwargs[k]:
|
||||
sys.argv.append("--" + ck)
|
||||
else:
|
||||
sys.argv.append("--" + ck)
|
||||
sys.argv.append(kwargs[k])
|
||||
|
Loading…
Reference in New Issue
Block a user