Gunicorn | Detect If Code Is Run With Wsgi Server
Context
Question
How to detect if code is run with wsgi server?
Answer
is_gunicorn = "gunicorn" in os.environ.get("SERVER_SOFTWARE", "")
# check if running via wsgi server. Gunicorn and uwsgi both support this.
# https://stackoverflow.com/a/25877937/3627387
IS_WSGI_SERVER = "SERVER_SOFTWARE" in environ