How to create a downloadable link for word document?

Hi everyone, I’ve tried to use streamlit app to do some kind of Word Docx automation works using the python docx package. After the script run I’ve got a document object, is there any way to provide a downloadable link for users to download the document object?

Reference for the package documentation:Document objects — python-docx 0.8.10 documentation

same question

The general solution for providing a download link/button can be seen at the following:

The general idea is that you take the object and convert it to bytes, then provide those bytes into a link using a Python f-string. The attached link has much more detail.