ben-pr-p
ben-pr-p8mo ago

Downloading a file

Is there a way to make a non-image file available for download that I generate on the fly? I want my users to be able to download a simple html file
12 Replies
Myles Scolnick
Myles Scolnick8mo ago
There is mo.ui.download Or maybe it’s just mo.download
ben-pr-p
ben-pr-pOP8mo ago
Oh thanks! mo.download, yep Can I include "<script>" tags in mo.Html that are executed? It doesn't seem to be working right now, not sure if I'm doing it wrong though
Myles Scolnick
Myles Scolnick8mo ago
They are not - we don’t allow it at the moment
ben-pr-p
ben-pr-pOP8mo ago
Gotcha. Maybe you have an idea for this pickle - I'm trying to generate HTML and then my user downloads it as a PDF. I know I can generate the PDF server side, and then use mo.download, but I'm trying to avoid complicated my Dockerfile with PDF generation dependencies I also have a version where I just give the user HTML and they print it themselves working, but then there's those ugly browser inserted headers and footers. I was trying to use js2PDF, but that requires script tags. Any other ideas? None of these bullets are too bad to bite, I'll figure out the Docker container eventually, just my least favorite thing to do :/
Myles Scolnick
Myles Scolnick8mo ago
Do you need to change docker that much? It should just be a few requirements.txt additions. Happy to video call tomorrow to help you through docker stuff
ben-pr-p
ben-pr-pOP8mo ago
Ok I'll bite the bullet 🙂 Every Python PDF generator I can find has additional system dependency requirements, which also are not that bad, but it's not just a poetry level change The one that has webkit just rough because the resulting Docker image is going to be pretty big, and my internet actually struggles to deploy that at my Alabama hotel, but if that's the best path, that's the best path 👍 Should just be a few extra apt-get install commands
Myles Scolnick
Myles Scolnick8mo ago
Ah I see why that can be annoying. We did want to add Export as PDF but I thought the deps wouldn’t be as hairy
ben-pr-p
ben-pr-pOP8mo ago
I have to ship Chrome pretty much lol, ugh. I'm going to accept the headers and footers. Thanks for your help!
Myles Scolnick
Myles Scolnick8mo ago
Probably a bit out of scope for the cloud stuff - but if it saves you a lot of time, I could look into adding an endpoint to convert html to pdf. I think I could do it fairly easily with some of our existing infra
ben-pr-p
ben-pr-pOP8mo ago
I found a good solution. I thought my users would have to print N documents (often 10-100), which is hard to do with html but easier with pdf since preview supports bulk open and print, but I figured I can use html page breaks to make it always 1 document It's a better user experience too Thanks so much for the offer though!
Myles Scolnick
Myles Scolnick8mo ago
That does sound like a better solution. Also I’m going to look into the multiple marimo apps under different routes tomorrow
ben-pr-p
ben-pr-pOP8mo ago
Thank you! Deploying my third tonight actually It's not the worst now that I've got it down, but it's just a waste of machine space and subdomains mostly 😉