Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Fastest way to turn a Jupyter notebook into a website these days?
82 points by janalsncm on April 4, 2023 | hide | past | favorite | 46 comments
I am mainly familiar with AWS but the configuration of S3, lambdas (including creating layers for python dependencies), api gateway, cloudfront, and all of the obscure permissions are just a major pain in the butt. I spent maybe 5 hours building something in Jupyter and then an entire day just dealing with AWS.

Is there an easier way? If I gave you a python script and some html what would you use to get it behind a www in the least amount of time possible?




No need to use AWS at all -

Jupyter Nbconvert: Jupyter Nbconvert is a command-line tool that allows you to convert Jupyter notebooks into various formats, including HTML, PDF, and Markdown. You can use the nbconvert command to convert your Jupyter notebook into an HTML file, which you can then upload to a web hosting service or a file-sharing platform like GitHub or GitLab. To use this method, you will need to have Jupyter installed on your computer.

Binder: Binder is a free service that allows you to turn your Jupyter notebook into a live, interactive website that can be accessed by anyone. Binder creates a virtual environment that includes all the dependencies required to run your notebook and launches it in a web browser. To use this method, you will need to upload your Jupyter notebook to a GitHub repository and provide a link to your repository to Binder.

Google Colab: Google Colab is a free cloud-based service that allows you to create and run Jupyter notebooks in a web browser. You can create a new notebook in Colab, write your code, and then export it as an HTML file using the nbconvert command. You can then download the HTML file and upload it to a web hosting service or file-sharing platform.


Binder is great! Here is an example of it in action, with a notebook in a github repo that solves fizbuzz 50 different ways. It is super easy on both the dev and user side. For the dev, just create a public git* repo, upload the ipynb, any data, and dependencies (requirements.txt, environment.yml, or Dockerfile). To use, no login or special permissions required, you can run it on anyone's public repo.

https://mybinder.org/v2/gh/quasiben/fiftyfizzbuzzes/master?f...


To be honest if you are comfortable writing Python you may want to just use plain old nbconvert. It'd take you a matter of minutes to get some kind of HTML output that you can then spend as much or as little time as you like customising by using your own templat, then publish somewhere using a shell script.

It's really not too tough: https://nbconvert.readthedocs.io/en/latest

Note that this is purely if you want to present your notebook as a static page. If you want it to be more interactive you're going to end up with something more complex.


I have a script [1] that converts a notebook into a markdown document, and places it in the content folder of my static site generator.

You can also just directly convert to html.

[1] https://gist.github.com/abdullahkhalids/142f0d28d4acf2c4c7e0...


Bit of a tangent, but one of the things I really like about livebook[0] is that the documents are just markdown, and the codecells are literally just ```elixir``` blocks which make it quite nice to read and very version control friendly.

[0] https://livebook.dev/


Im working on Mercury framework to solve this problem. Notebooks can be static or dynamic. You can hide code in notebook and show only outputs. You can easily add authentication.

The framework repository at GitHu https://github.com/mljar/mercury

Im working also on cloud offering so you will upload notebooks and set domain. It is available in alpha at https://cloud.runmercury.com


What is advantage of Mercury over Streamlit? You don't need to rewrite your code into Python script. You can serve notebook with its charts, dataframes and Markdown. If you want you can show/hide code. You can share multiple notebooks (websites). There is authentication and PDF export.

What is advantage over Viola? Mercury offers cloud service for deployment. You just upload notebook to make a website. That's it.

What is advantage over Gradio? Gradio is a framework for show casing ML models. You provide input for ML model with widgets and compute the prediction (output). Mercury can be used for show casing ML models, data science reports, dashboards and even scientific presentations (with slides recomputing after widget update)


Quarto is a thing https://quarto.org/


Maybe not the fastest, but has a lot of features to build a whole website with notebooks (various kind), Markdown, custom HTML if needed.


You can build web apps from Jupyter using Datapane [0]. I'm one of the founders, so let me know if I can help at all.

You can either export a static site [1] (and host on GH pages or S3), or, if you need backend logic, you can add Python functions [2] and serve on your favourite host (we use Fly).

We have specific Jupyter integration to automatically convert your notebook into an app [3].

[0] https://github.com/datapane/datapane

[1] https://docs.datapane.com/reference/reports/#datapane.proces...

[2] https://docs.datapane.com/apps/overview/

[3] https://docs.datapane.com/reports/jupyter-integration/#conve...


Upload to Google colab, share link?

Not very polished I admit but it's allowed a recent prototype I built to get enough traction that someone else wants to build the proper version now. I'll tell them to come and check this thread ;-)

(Plot twist if that person is op...)


Is the goal for users to be able to execute notebook code, or just view the notebook?

If interactive, http://tmpenv.com lets you clone a github repo repo, drop your notebook in, and gives you a button for spinning up instances of it. We’re a few weeks away from making it generally available but I’m happy to give you access if you’re interested.

If not interactive, most static hosting sites will let you run nbconvert to turn an ipynb file into HTML.


Good question. If you just need to get something up as a demo, PythonAnywhere seems quite good. But if you need something simple that you can deploy to production, I too would like hear recommendations.

Plotly Dash is a pretty painless all-python-no-javascript way to build an interactive UI on top of whatever your data source is, but I have no idea how well (or not) it scales.


Perhaps https://github.com/voila-dashboards/voila?

Not sure about ease relative to other alternatives.


From the Jupyter front page itself:

> Voilà helps communicate insights by transforming notebooks into secure, stand-alone web applications that you can customize and share.


If civilian hardware is enough, try jupyterlite - runs 100% in the browser

https://jupyterlite.readthedocs.io/en/latest/try/lab/

Can be hosted out of GitHub pages.


Maybe replit.com for hosting seeing as you mention "python script and HTML" at the end. The simplest way I've seen to go from code -> hosted URL.

If you want to use an actual .ipynb file as the "python script", then I'd add in Streamlit.

Probably a bit dated now, but I tried a bunch of these tools when I was working on a comparison article[0] that might still be useful.

https://www.datarevenue.com/en-blog/data-dashboarding-stream...


jupyter books on github pages https://jupyterbook.org/en/stable/


Upload your ipynb to Deepnote and publish as an app. That simple.

https://deepnote.com


In the past, I just run it inside a docker container, and expose port 8888 to the network.

Example (not my repo) - https://github.com/MKAbuMattar/dockerized-jupyter-notebook/b...


Can I ask what you're expecting out of this? Because if you're generating something static... then just render it to html and upload, generally with stuff like plotly it'll even handle the javascript to let you have interactive charts. If you're talking about publishing the notebook and expecting people to modify it and run it then then as other people have said there are services that host notebooks as a service, you shouldn't be AWSing that yourself. If you want something that looks more like a website, allowing users to modify stuff within bounds but quite well structured then something like Dash might be good (but make sure to preprocess your data), and they've got ways of plugging into cloud for deployment.


I'm curious what comes to people's minds reading this - as in is there some "usual" turn-a-notebook-into-a-website task?

Forgive my probably being pedantic: if it's the whole notebook with all it's functionality of changing code in cells that's to be shared, I'd have said colab as someone else did.

If it's some of the plots or data frames to be visualized with some means of adjusting them, streamlit or a similar product, as long as it doesn't have to be too polished. Or plotly/dash? (Irrc, I may have the name wrong).

Or if it's just running some code and returning something, flask, e.g. could be fine.

Imo it really depends on the use case.



On that note, is there some site where I can host regular html, JavaScript etc but I don't write the code locally but on some web ide? I'd like to say, save my file and see the change pop up on my public domain instantly after a refresh. I don't want to worry about hooking up ssh or rsync tunneling or any file uploads. All files and code should be directly edited through the web ide and live on the remote server.


"Turning jupyter notebook into a website" is a very broad task. From the question body I gather the specific task is to deploy a jupyter notebook server. For that you just need a generic VM, install and start up jupyter with the right configuration options about authorization and ports, then point a dns and preferably a reverse proxy with SSL to it. That shouldn't require S3, lambdas, api gateway, cloudfront and so on, even on AWS.


I use nbconvert and upload to Github Pages. I also put the .ipynb file up there in case anybody wants to try using my code. I've also tried Colab and Jupyter Lite, both work fine.

None of these produce slick professional-looking pages, but I prefer just exposing my source code and letting people use it. Also, my stuff isn't profound enough to deserve real web hosting, or the effort to turn it into "software."


I would probably go with Streamlit - it's really very easy to turn a python script into something good looking.

If it's supposed to serve a lot of users, then Dash.


I don't have much experience with them but I think Paperspace.com might be worth a look. I think it's positioned sort of like Heroku for ML.


Have you tried using the free tier of Hex (https://www.hex.tech)?


Consider making a Streamlit or Gradio app and hosting it at Hugging Face Spaces: https://huggingface.co/spaces/launch This allows you to make a simple frontend using Python only, then host it for free.


Binder is relatively easy to use but it hasn't been always very reliable. Not sure if that changed. I haven't tried it in a long time. URL: https://mybinder.org/


My suggestion is https://panel.holoviz.org/

Fully open sourced, makes it easy to make reactive apps with small changes, can even configured as a graphical REPL.


That's the worst combination of things I've ever heard of. If you have python chops just use Streamlit or Django. If not then what's stopping you from using Markdown



Convert to orgmode using

    jupyter nbconvert --to orgmode a.ipynb
Then export it directly from orgmode to html (or pdf or latex or info or ...)


Can vouch for both Quarto and Jupyter Book.

Used both tens of times.


your task is very very broad

you mention you don't want to deal with AWS, if it's because of ad-hoc installation concerns and nothing else you can just run your notebooks in ready-made solutions like Google Colab, or Jupyter-book in Github ( https://github.com/executablebooks/jupyter-book ))

that would cover a lot of use cases right away without next to no learning curve

If you don't want to deal with AWS or similar, in that case:

- if it's a static notebook then you can obviously render it and serve the web content (might seem obvious but needs to be considered)

- if it's dynamic but has light hardware requirements, you can try jupyterlite which runs in the browser and should do a pyodine (webassembly CPython kernel) can do: https://jupyterlite.readthedocs.io/en/latest/try/lab/

- otherwise, you can try exposing a dockerised jupyter env ( as in https://github.com/MKAbuMattar/dockerized-jupyter-notebook/b... ) or even better a nixified one ( https://github.com/tweag/jupyenv )

there might be other approaches I'm missing, but I think that's pretty much it that doesn't entail some proprietary solution or an ad-hoc installation as you've been doing


Why downvoted? This was a very thorough answer, with items other posts don't contain.


perhaps my mention that other solutions are proprietary was not welcome by the purveyors of such solutions



DAE find jupyter notebooks cumbersome to use for serious research?


I hate to say it, but probably ChatGPT.


ChatGPT recommended a self-hosted instance of JupyterHub.


You could check out Anvil.


Google Colab


Probably at minimum something running in a sandbox like Docker.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: