Merge pull request #2237 from dalf/mod-engines-init

Mod engines init
This commit is contained in:
Alexandre Flament 2020-10-05 11:20:46 +02:00 committed by GitHub
commit 584760cf54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 7 deletions

View file

@ -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')