skip to Main Content

I have an Azure webapp that runs streamlit.

It connects to SQL, does some processing, and generates a ppt deck

with col1:
    result = st.button("Generate entire Summary deck")
if result:
    t1 = pd.Timestamp.now()
    st.write(f'Started at {str(pd.Timestamp.now().time())}')
    subprocess.run(["Rscript", "summary_fcn.R", quarter])

    
    prs = summary_fcn.create_summary_ppt(quarter)
    # save the output into binary form
    binary_summary = BytesIO()
    prs.save(binary_summary) 
    st.write(f'generated in {str(pd.Timestamp.now()-t1)}')
with col2:
    st.download_button(label = 'Download Summary',
                   data = binary_summary.getvalue(),
                   file_name = 'Summary_'+ quarter + '_' + str(pd.Timestamp.now())[2:-7].replace('-','').replace(' ','_').replace(':','') + '.pptx')
 

It used to work perfectly, but then as of yesterday, it has consistently failed.

i have been searching to try and find potential causes with no success. Can anyone offer any possible reasons this might happen?

I frequently see

enter image description here

when I try to download.

does the accompanying address have any implication:

62fd0f8221f7c5b0fc01e5f7815afafcf3a0065950bf596d3a8a1451.bin?title=app%20·%20Streamlit

2

Answers


  1. Chosen as BEST ANSWER

    Thanks for the suggestion @siddhesh Desai, but after playing around with the Portal, I found one suggestion from MSFT caused it to break down (putting the app on multiple instances). I removed the multiple instances and it worked ok

    MSFT suggested goto 3, I changed it back and it worked enter image description here


  2. I tried the below code to run the Streamlit app locally and it is running in the browser like below:-

    import pandas as pd
    
    import streamlit as st
    
    from io import  BytesIO
    
      
    
    # Define your own functions for generating summary data and creating the PowerPoint presentation
    
    def  generate_summary_data(quarter):
    
    # Code to generate summary data goes here
    
    summary_data = pd.DataFrame()
    
    return  summary_data
    
      
    
    def  create_ppt(summary_data, quarter):
    
    # Code to create PowerPoint presentation goes here
    
    prs = ...
    
    return  prs
    
      
    
    # Define the Streamlit app
    
    def  main():
    
    # Define your input parameters
    
    quarter = st.text_input('Enter quarter (e.g., Q1 2022):')
    
      
    
    # When the button is clicked, generate the summary data and PowerPoint presentation
    
    if st.button('Generate Summary'):
    
    # Generate the summary data
    
    summary_data = generate_summary_data(quarter)
    
      
    
    # Create the PowerPoint presentation
    
    prs = create_ppt(summary_data, quarter)
    
      
    
    # Save the output into binary form
    
    binary_summary = BytesIO()
    
    prs.save(binary_summary)
    
      
    
    # Display the download button for the user to download the summary
    
    st.download_button(label='Download Summary',
    
    data=binary_summary.getvalue(),
    
    file_name=f'Summary_{quarter}.pptx')
    
      
    
    # Run the Streamlit app
    
    if  __name__ == '__main__':
    
    main()
    
    

    Make sure you add the required modules in your requirements.txt file like below:-

    pandas
    streamlit
    

    enter image description here

    For streamlit to work you need to create your Web app above B1 SKU.

    enter image description here

    I deployed the above code in Azure Web app like below:-

    enter image description here

    I tried accessing the Azure web app link after deployment and it gave me an error, I added the below command in my Azure Web app startup command configuration:-

    python -m streamlit run app.py --server.port 8000 --server.address 0.0.0.0
    
    

    enter image description here

    Select Python version 3.10 as a minor version for Streamlit to run. Selected HTTPS Only to Off like below:-

    Even when Https is set to off, You can browse your website using HTTPS protocol.

    enter image description here

    Output:-

    enter image description here

    In order to resolve the 404 error while downloading the PPT file, Check Diagnose and solve problem tab of your Azure Web app Refer below:-

    enter image description here

    Check the log stream for the error code and its resolution like below:-

    enter image description here

    In order to resolve the 404 error while downloading your PPT Deck from Streamlit app in Azure check if:-

    You’re using Incomplete or wrong URL: The file’s URL may be problematic. Ensure that the URL contains the complete file path, including any required subdirectories.
    If you’re Unable to open file: It’s possible that the file has been moved or deleted, or that the filename is misspelt. Verify that the file is still there in the required location and that its name corresponds to the one on the download button. And the function to call the file is properly coded.
    Try downloading the file in another browser InPrivate window. Verify if the URL to access the file is correct. Restart your web app and try the download operation again.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search