How to check if python is running as a click cli command instead of the flask server?
This is a bit of a hack but it worked for me:
# detect if we are running the app.# otherwise we are running a custom flask command.command_line = ' '.join(sys.argv)is_running_server = ('flask run' in command_line) or ('gunicorn' in command_line)if is_running_server: # do stuff that should only happen when running the server.