I have a Flask API app that returns some JSON with http status code set to 422.
Example
def post(self, current_user, data):
return {
"success": False,
"message": "blah blah"
}, 422
When I run the app with python, I get the JSON and the 422 status code.
When I run the app with gunicorn, I get “Internal Server Error” with a 500 status code.
Is there any way to tell gunicorn to let my Flask app return the JSON with the 422 status code?
Thanks!
Environment
Debian Linux 12
docker 20.10.17
python 3.11
gunicorn 22.0.0
gunicorn_config.py
import os
workers = int(os.environ.get('GUNICORN_PROCESSES', '2'))
threads = int(os.environ.get('GUNICORN_THREADS', '4'))
bind = os.environ.get('GUNICORN_BIND', '0.0.0.0:5555')
forwarded_allow_ips = '*'
secure_scheme_headers = { 'X-Forwarded-Proto': 'https' }
certfile = os.environ.get('GUNICORN_CERTFILE', '/etc/letsencrypt/live/example.com/fullchain.pem')
keyfile = os.environ.get('GUNICORN_KEYFILE', '/etc/letsencrypt/live/example.com/privkey.pem')
ca_certs = '/etc/ssl/certs/ca-certificates.crt'
Python Start Command
pipenv run python src/run.py
Gunicorn Start Command
gunicorn --config gunicorn_config.py run:app