1
0
mirror of https://github.com/LibreTranslate/LibreTranslate.git synced 2024-12-18 08:27:03 +02:00
LibreTranslate/wsgi.py

23 lines
481 B
Python
Raw Normal View History

from libretranslate import main
2021-07-07 02:26:06 +02:00
2021-07-07 02:26:06 +02:00
def app(*args, **kwargs):
import sys
sys.argv = ['--wsgi']
2024-08-12 19:58:32 +02:00
2021-07-07 02:26:06 +02:00
for k in kwargs:
ck = k.replace("_", "-")
2024-08-12 19:58:32 +02:00
if isinstance(kwargs[k], bool):
if kwargs[k]:
sys.argv.append("--" + ck)
2021-07-07 02:26:06 +02:00
else:
sys.argv.append("--" + ck)
sys.argv.append(kwargs[k])
instance = main()
if len(kwargs) == 0:
return instance(*args, **kwargs)
else:
return instance