Showing PDF file on StreamlitSharing that's in github directory

Hi, i am building an app that does timeseries forecasting and would like to show a pdf instruction file on my about section. The problem is, it isnt showing in streamlit sharing but it is showing when i run it in browser locally. Here is examples and the code i used.

Locally:

Sharing:


image

Code:

    if st.checkbox("Show Instructions"):
        def show_pdf(file_path):
            with open(file_path,"rb") as f:
                  base64_pdf = base64.b64encode(f.read()).decode('utf-8')
            pdf_display = f'<embed src="data:application/pdf;base64,{base64_pdf}" width="700" height="1000" type="application/pdf">'
            st.markdown(pdf_display, unsafe_allow_html=True)
        st.write(show_pdf("DFCU_Instructions_on_GUI.pdf"))

Possible anyone can tell me why it is showing None? and How i can fix this or have any other method to showcase an instruction pdf file in streamlit sharing, or maybe a download link where they can download the file that is on my public github?

My guess would be that Streamlit starts in a different directory on sharing than you are locally. Meaning, you relative file reference in show_pdf doesn’t exist, so Python shows None

Perhaps you could try using pathlib to programmatically determine where you file actually is?

Best,
Randy