I have created a streamlit app which runs fine on my local machine. However, I cannot get it running on the streamlit-cloud. In a nutshell my app does the following:
take some user input
create a markdown file from the input (“deck.md”)
convert markdown file to html file (“deck.html”) using npx command via subprocess
opens a new tab showing the html file via subprocess
On my local machine I use the following command to do steps 3 and 4:
import subprocess
def markdown2marp(file):
# Create HTML
marp_it = f"npx @marp-team/marp-cli@latest --theme custom.css --html {file}"
# Open HTML in Browser
file = file.split(".")[0] # remove .md
proc = subprocess.run([marp_it], shell=True, stdout=subprocess.PIPE)
subprocess.Popen(['open', f'{file}.html'])
return proc
Now on the streamlit cloud this is not working. How can I achieve the above withouth using subprocess? Is it even possible? If so could you give me some ideas how I could achieve this?
Hi @fredzett, welcome to the community! I would recommend you change the logic of your app to do the following:
Accept user input
Convert the user input to markdown
Convert eh markdown file to HTML using a python package and offer it to be downloaded via the st.download_button() function (maybe using md-to-html · PyPI)
When the user downloads the file and opens it, it will automatically open a new browser window.
The tutorial does not solve my problem. Reason being that I do not try to run python in subprocess I guess.
Meanwhile I have concluded that running the npx command using subprocess does work.
However, the resulting html file cannot be opened using subprocess. So I tried two other options (both of which work on my local machine).
using webbrowser module to open the html file I have created. There is no error message, but the file does also not open using streamlit-cloud.
using a download button to download the html file. This results in the following error message using streamlit-cloud.
I use the following code block to download the html-file:
with open("deck.html", 'rb') as f:
st.download_button(
label="Download presentation",
data=f.read(),
file_name="deck.html",
mime='application/xhtml+xml',
)
But I do get this error message.
FileNotFoundError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you're on Streamlit Cloud, click on 'Manage app' in the lower right of your app).
Where is the file I create via my streamlit app located in the cloud?
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.