Reputation: 677
I am really new to IPython/Jupyter notebook. I just created one notebook (.ipynb) and I want to share it on my webpage. Specifically, I want to add a link, and when people click it, it will open a new "webpage" where they can "view" my code and results.
Note: I cannot use github, it is a huge pain for me.
I tried nbviewer (http://nbviewer.jupyter.org/). It has several options but only one of them (url) is not related to github/gist. So, in order to have an URL for my file, I uploaded it to google drive, and got a public link for the file. On the other hand, when I put that link to nbviewer (as url to my file), it says "there is no file in this url". On the other hand, I know the link works, because when I put it on browser, it directs me to download the .ipynb file.
Upvotes: 48
Views: 144735
Reputation: 44605
There appears to be limited non-GitHub options for sharing notebooks. You can still share a link directly from Google's colaboratory. This will allow you to:
Any Google user can view (and optionally edit) your notebook.
See also other options:
Upvotes: 51
Reputation: 5859
If you want to share your Python notebook so others can view it, then you can try an open-source framework called Mercury. The Mercury converts notebook to a web app. Additionally, you can add interactive widgets for your notebook by simply inserting the YAML config in the first raw cell of the notebook.
Here is example notebook with the YAML config:
and this is the web app view generated for the notebook by Mercury:
You can deploy Mercury to any server because it is built on top of Django framework.
Upvotes: 0
Reputation: 125
A code below is a simple viewer for Jupyter notebooks. It can be used to preview quickly ipynb-files. Use the code as python jnv.py a.ipynb
, where 'jnv.py' is the code below. The code can also be used in file managers, like Total Commander, if one assigns command python jnv.py
as a viewer of ipynb-files.
# jnv.py: A simple viewer of a Jupyter notebooks (ipynb-files).
# Works for nbformat version >= 4.
import tkinter as tk
import sys,json
f = open(sys.argv[1], 'r', encoding="utf8") # input.ipynb
jf = json.load(f)
f.close()
# Take text ('source') from 'markdown' and 'code' cells
out_txt = ''
for cell in jf["cells"]:
if cell['cell_type'] == 'markdown':
for el in cell['source']:
out_txt = out_txt + el
elif cell['cell_type'] == 'code':
for el in cell['source']:
out_txt = out_txt + el
# Make a frame and display 'out_txt'. Press Esc to quit.
# See https://www.python-course.eu/tkinter_text_widget.php
root = tk.Tk()
S = tk.Scrollbar(root)
T = tk.Text(root, height=24, width=80)
def select_all(event=None):
T.tag_add('sel', '1.0', 'end')
#return "break"
def copy_sel(event=None):
content = T.selection_get()
print(content)
root.clipboard_clear()
root.clipboard_append(content)
def key(event):
print(event)
if event.keycode == 27: # pressed Esc
root.destroy()
elif event.char == '\x01': # Ctrl-A; make sure you use this before cursor enters text!
select_all()
elif event.char == '\x03': # Ctrl-C; make sure you use this before cursor enters text!
copy_sel()
S.pack(side=tk.RIGHT, fill=tk.Y)
T.pack(side=tk.LEFT, fill=tk.Y)
S.config(command=T.yview)
T.config(yscrollcommand=S.set)
T.insert(tk.END, out_txt)
root.bind("<Key>", key)
tk.mainloop()
Upvotes: 3
Reputation: 483
Checkout this Firefox plugin. Python Notebook Viewer
Its is easy to use, Does not require you to open terminal/command prompt and can be used offline as well. Just follow steps below.
Chrome version : Jupyter Notebook Viewer
Not the same developer but works the same way, globally.
Upvotes: 26
Reputation: 1368
As you already created a notebook file, you can easily convert it to an html file. In this format it will be easy for you to share it or put it on a website. So from the prompt :
jupyter nbconvert --to html --execute YOUR_FILE.ipynb --output OUTPUT.html
There is also other format : markdown, html, pdf, ipynb, etc
Upvotes: 15