未验证 提交 5208d7f4 编写于 作者: C chenjian 提交者: GitHub

update app for flask babel api (#1201)

上级 1ba9b4c2
......@@ -71,7 +71,15 @@ def create_app(args): # noqa: C901
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 30
app.config['BABEL_DEFAULT_LOCALE'] = default_language
babel = Babel(app)
def get_locale():
lang = args.language
if not lang or lang not in support_language:
lang = request.accept_languages.best_match(support_language)
return lang
babel = Babel(app, locale_selector=get_locale) # noqa:F841
# Babel api from flask_babel v3.0.0
api_call = create_api_call(args.logdir, args.model, args.cache_timeout)
profiler_api_call = create_profiler_api_call(args.logdir)
inference_api_call = create_model_convert_api_call()
......@@ -88,13 +96,6 @@ def create_app(args): # noqa: C901
query_string = '?' + request.query_string.decode()
return url + query_string
@babel.localeselector
def get_locale():
lang = args.language
if not lang or lang not in support_language:
lang = request.accept_languages.best_match(support_language)
return lang
if not args.api_only:
template = Template(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册