Serving streamlit app using gunicorn in prod deployment

serving streamlit app using gunicorn in prod deployment
I have this basic streamlit app which looks like this

import streamlit as st

x = st.slider('Pick a number')
st.write('You picked:', x)

i want to use gunicorn to serve my app in deployment. How do i do that ?

Hi @qxlsz,

At this time Streamlit doesn’t support the WSGI protocol (linking here to the Tornado page about it, since Streamlit uses Tornado as a framework), so there’s no directly usable connection between gunicorn and Streamlit. (For more context, check out this quick article about what Gunicorn can and can’t do.)

I’d recommend checking out this thread regarding deploying streamlit in a manner that resembles using gunicorn.

Thanks for your question; let us know how it goes!

1 Like

I was also looking for a way to combine a WSGI application with Streamlit. This thread clarified that I was making the wrong assumption that Streamlit was using a WSGI-compatible web server.

From the tornado docs:

The Tornado web framework and HTTP server together offer a full-stack alternative to WSGI. While it is possible to use the Tornado HTTP server as a container for other WSGI frameworks ( WSGIContainer ), this combination has limitations and to take full advantage of Tornado you will need to use Tornado’s web framework and HTTP server together.