marimo-team / marimo

A reactive notebook for Python — run reproducible experiments, execute as a script, deploy as an app, and version with git.
https://marimo.io
Apache License 2.0
6.13k stars 199 forks source link

Export WASM to folder for self-publishing on personal web site #1110

Open akshayka opened 5 months ago

akshayka commented 5 months ago

Discussed in https://github.com/marimo-team/marimo/discussions/1078

Originally posted by **astrowonk** April 5, 2024 marimo.app is very cool and I was excited to see the WASM support. But, WASM apps should be able to just be turned into a folder than can deployed on any web server (nginx, apache, etc.) [Shiny Live](https://github.com/posit-dev/py-shinylive) for example has an easy `shinylive export myapp site` command that turns the app into a folder I can upload to my nginx server. Whereas for now, wasm notebooks seem to require using `marimo.app`. Is there a plan to have an export option someday? Thanks!
akshayka commented 5 months ago

Some follow up from that discussion:

We don't support such an export yet. In the meantime, one can iframe marimo.app URLs (https://docs.marimo.io/guides/wasm.html#embedding).

@astrowonk mentioned working with local files as a use case that makes marimo.app links difficult to use. We do have a beta sandbox that lets you attach files to WASM notebooks, via the browser's storage; I'm not actually sure how you'd do it via a static export.

@astrowonk and others who have requested this: are local files the only reason you need exports? We'd appreciate more feedback before going down this route, since it will take us some time.

astrowonk commented 5 months ago

I would say I have a few reasons for wanting WASM export, though I could be in the minority so even if this is important to me, it is no guarantee it's worth your development time (yet.)

dmadisetti commented 5 months ago

If this export of the tutorials was reactive - would that solve your use case?

https://dmadisetti.github.io/quarto-marimo/intro.html

astrowonk commented 4 months ago

If this export of the tutorials was reactive - would that solve your use case?

https://dmadisetti.github.io/quarto-marimo/intro.html

I think … so? I mean the idea is to get WASM-goodness that is on marimo.app but self-hosted on any web server (plus being able to be import code from other python files in the same directory). I'd love to someday type marimo export notebook.py notebook_folder and copy that the resulting folder to a directory on my web site, and have a live interactive notebook.

superlopuh commented 1 month ago

Building on this, it would also be great to have a way to generate the wasm permalink programmatically, similarly to the marimo export html, just with the wasm version in the iframe.

mscolnick commented 1 month ago

You can do this without the marimo CLI. The link is just https://marimo.app/#code/{url_encoded_code}

url_encoded_code is URL escaped code which is just urllib.parse.quote(code, safe="~()*!.'")

but you will hit a 2mb limit that is imposed by your browsers (not the server)

astrowonk commented 1 month ago

You can do this without the marimo CLI. The link is just https://marimo.app/#code/{url_encoded_code}

url_encoded_code is URL escaped code which is just urllib.parse.quote(code, safe="~()*!.'")

but you will hit a 2mb limit that is imposed by your browsers (not the server)

Yes, that’s useful for some contexts, but I don’t want it to be limited to what can be encoded in a url. And I want to access other data locally (parquet, csv, sqlite, etc.)