diff options
author | Alexandre Flament <alex@al-f.net> | 2020-10-01 14:18:00 +0200 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2020-10-05 11:13:32 +0200 |
commit | 6c39917c4d3e3d3d6ced3fc14d1c78842fec3a19 (patch) | |
tree | c6712bad1b047b3ad7a79a8510eb14bc0135d7c9 /searx/webutils.py | |
parent | 2cafc5462d9b58c4a19a336c8b79d55bb9166913 (diff) | |
download | searxng-6c39917c4d3e3d3d6ced3fc14d1c78842fec3a19.tar.gz searxng-6c39917c4d3e3d3d6ced3fc14d1c78842fec3a19.zip |
[mod] webapp.py: update engines initialization condition
Always call initialize engines except on the first run of werkzeug with the reload feature.
the reload feature is activated when:
* searx_debug is True (SEARX_DEBUG environment variable or settings.yml)
* FLASK_APP=searx/webapp.py FLASK_ENV=development flask run (see https://flask.palletsprojects.com/en/1.1.x/cli/ )
Fix SEARX_DEBUG=0 make docs
docs/admin/engines.rst : engines are initialized
See https://github.com/searx/searx/issues/2204#issuecomment-701373438
Diffstat (limited to 'searx/webutils.py')
-rw-r--r-- | searx/webutils.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/searx/webutils.py b/searx/webutils.py index 2900c0edd..bf50dbc25 100644 --- a/searx/webutils.py +++ b/searx/webutils.py @@ -4,6 +4,7 @@ import csv import hashlib import hmac import re +import inspect from io import StringIO from codecs import getincrementalencoder @@ -125,3 +126,18 @@ def highlight_content(content, query): content, flags=re.I | re.U) return content + + +def is_flask_run_cmdline(): + """Check if the application was started using "flask run" command line + + Inspect the callstack. + See https://github.com/pallets/flask/blob/master/src/flask/__main__.py + + Returns: + bool: True if the application was started using "flask run". + """ + frames = inspect.stack() + if len(frames) < 2: + return False + return frames[-2].filename.endswith('flask/cli.py') |