Python flask: troubleshooting

From wikinotes

Flask hosted behind proxy at a sublocation

http:domain.com/api/test  # external URL

127.0.0.1:5000/test       # internal URL (note missing 'api/')

If your flask app is being routed to by a proxy, at a sublocation, flask.url_for() will not work properly (it will return the route without the sublocation).

You can fix this using: https://github.com/antarctica/flask-reverse-proxy-fix


Second SQL query fails SSL error: decryption failed or bad record mac

This is caused when your WSGI server shares a postgres database session between multiple processes.

Create your flask app in a function. Refer to that function in gunicorn to get your app.

gunicorn \