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

Allow json submission to /suggest

This commit is contained in:
Robert George 2023-09-29 13:49:52 -07:00
parent 81ba2b81e9
commit cb11dfc6b1
No known key found for this signature in database
GPG Key ID: 9B0D835A293663C4

View File

@ -1038,10 +1038,17 @@ def create_app(args):
if not args.suggestions:
abort(403, description=_("Suggestions are disabled on this server."))
q = request.values.get("q")
s = request.values.get("s")
source_lang = request.values.get("source")
target_lang = request.values.get("target")
if request.is_json:
json = get_json_dict(request)
q = json.get("q")
s = json.get("s")
source_lang = json.get("source")
target_lang = json.get("target")
else:
q = request.values.get("q")
s = request.values.get("s")
source_lang = request.values.get("source")
target_lang = request.values.get("target")
if not q:
abort(400, description=_("Invalid request: missing %(name)s parameter", name='q'))