from gevent import monkey
monkey.patch_all()
from CTFd import create_app

app = create_app()

if __name__ == '__main__':
    app.run(debug=True, threaded=True, host="127.0.0.1", port=4000)

wsgi.py
import os

# Detect if we're running via `flask run` and don't monkey patch
if not os.getenv("FLASK_RUN_FROM_CLI"):
    from gevent import monkey

    monkey.patch_all()

from CTFd import create_app

app = create_app()

if __name__ == "__main__":
    app.run(debug=True, threaded=True, host="127.0.0.1", port=4000)

wsgi.py
diff --git a/wsgi.py b/wsgi.py
index b66234e2c..c9fb2d114 100644
--- a/wsgi.py
+++ b/wsgi.py
@@ -1,8 +1,14 @@
-from gevent import monkey
-monkey.patch_all()
+import os
+
+# Detect if we're running via `flask run` and don't monkey patch
+if not os.getenv("FLASK_RUN_FROM_CLI"):
+    from gevent import monkey
+
+    monkey.patch_all()
+
 from CTFd import create_app
 
 app = create_app()
 
-if __name__ == '__main__':
+if __name__ == "__main__":
     app.run(debug=True, threaded=True, host="127.0.0.1", port=4000)

CTFd crash right after install
## Git + python 3.7.2 (3b1b82b9a0fbcb8731d7a3a3bbac99499c466c99)

[![asciicast](https://asciinema.org/a/iHDMVNRWSYJDTZUgIy4wIBsOK.svg)](https://asciinema.org/a/iHDMVNRWSYJDTZUgIy4wIBsOK)

## Git + python 2.7.15 (3b1b82b9a0fbcb8731d7a3a3bbac99499c466c99)

[![asciicast](https://asciinema.org/a/JRqfe0rMl0QeZAEklyvV1LQX9.svg)](https://asciinema.org/a/JRqfe0rMl0QeZAEklyvV1LQX9)

## 2.1.4 + python 3.7.2

[![asciicast](https://asciinema.org/a/wErebw8ZN2HFER9P71tLW4FBv.svg)](https://asciinema.org/a/wErebw8ZN2HFER9P71tLW4FBv)

**Environment**:

  - CTFd Version/Commit: see titles
  - Operating System: ArchLinux
  - Web Browser and Version: Firefox

**What happened?**

CTFd crash right after install.

**What did you expect to happen?**

Working or at least a more comprehensible error.

**How to reproduce your issue**

See the asciinema, but basically

- Download CTFd
- Install dependencies
- run flask
- crash

PS : with the untouched default config

**Any associated stack traces or error logs**

See the asciinema
