summaryrefslogtreecommitdiff
path: root/searx/webutils.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2020-10-05 11:20:46 +0200
committerGitHub <noreply@github.com>2020-10-05 11:20:46 +0200
commit584760cf5419051bd3f37e733147e048356f7ffc (patch)
tree54990d1a734034f37a0c265de913095cb788efab /searx/webutils.py
parentb728cb610b92161609b1c40babff25749720fc25 (diff)
parent6c39917c4d3e3d3d6ced3fc14d1c78842fec3a19 (diff)
downloadsearxng-584760cf5419051bd3f37e733147e048356f7ffc.tar.gz
searxng-584760cf5419051bd3f37e733147e048356f7ffc.zip
Merge pull request #2237 from dalf/mod-engines-init
Mod engines init
Diffstat (limited to 'searx/webutils.py')
-rw-r--r--searx/webutils.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/searx/webutils.py b/searx/webutils.py
index 6dd0243d8..8be8fcecd 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
@@ -127,3 +128,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')