update readme, make path generic

This commit is contained in:
Tim Paine 2018-03-26 15:14:04 -04:00
parent eaa7a5d55a
commit 8536aa0132
2 changed files with 12 additions and 1 deletions

View file

@ -3,6 +3,13 @@ Open a site in a widget, or add a set of "quicklinks".
![](https://raw.githubusercontent.com/timkpaine/jupyterlab_iframe/master/docs/example1.gif)
## Install
```bash
pip install jupyterlab_iframe
jupyter labextension install jupyterlab_iframe
jupyter serverextension enable --py jupyterlab_iframe
```
## Adding quicklinks
install the server extension, and add the following to `jupyter_notebook_config.py`

View file

@ -1,5 +1,6 @@
import ujson
from notebook.base.handlers import IPythonHandler
from notebook.utils import url_path_join
class IFrameHandler(IPythonHandler):
@ -20,6 +21,9 @@ def load_jupyter_server_extension(nb_server_app):
web_app = nb_server_app.web_app
iframes = nb_server_app.config.get('JupyterLabIFrame', {}).get('iframes', [])
host_pattern = '.*$'
base_url = web_app.settings['base_url']
print('Installing jupyterlab_iframe handler on path %s' % '/iframes')
print('Handinling iframes: %s' % iframes)
web_app.add_handlers(host_pattern, [('/iframes', IFrameHandler, {'iframes': iframes})])
web_app.add_handlers(host_pattern, [(url_path_join(base_url, '/iframes'), IFrameHandler, {'iframes': iframes})])