mirror of
https://github.com/searx/searx
synced 2024-11-25 11:19:48 +01:00
Avoid UnicodeEncodeError when redirecting standalone output
This commit is contained in:
parent
077d8efed8
commit
cda9f8593f
@ -25,6 +25,8 @@ path.append(realpath(dirname(realpath(__file__)) + '/../'))
|
|||||||
# initialization
|
# initialization
|
||||||
from json import dumps
|
from json import dumps
|
||||||
from searx import settings
|
from searx import settings
|
||||||
|
import sys
|
||||||
|
import codecs
|
||||||
import searx.query
|
import searx.query
|
||||||
import searx.search
|
import searx.search
|
||||||
import searx.engines
|
import searx.engines
|
||||||
@ -97,5 +99,6 @@ result_container_json = {
|
|||||||
"paging": result_container.paging,
|
"paging": result_container.paging,
|
||||||
"results_number": result_container.results_number()
|
"results_number": result_container.results_number()
|
||||||
}
|
}
|
||||||
|
sys.stdout = codecs.getwriter("UTF-8")(sys.stdout)
|
||||||
|
sys.stdout.write(dumps(result_container_json, sort_keys=True, indent=4, ensure_ascii=False, encoding="utf-8", default=json_serial))
|
||||||
|
|
||||||
print(dumps(result_container_json, sort_keys=True, indent=4, ensure_ascii=False, encoding="utf-8", default=json_serial))
|
|
||||||
|
Loading…
Reference in New Issue
Block a user