Download
Running on Command Line
# create a csv file with a name from encoded string of three concatenated strings
s1 = '100'
s2 = '2012'
s3 = 'Washington University'
import base64
encoded = base64.b64encode((s1+s2+s3).encode())
import os
name = encoded.decode()+'.csv'
location = os.path.join('downloads', name)
with open(location, 'wb') as f:
f.write(b'Hello World!')
# create a download link
import ipywidgets as widgets
widgets.HTML(
value='<a href = \"'+location+'\">Download</a>',
)
# start voila server
voila --VoilaConfiguration.file_whitelist="['.*']" name.ipynb
Running from Jupyter Notebook
# create jupyter_notebook_config.py under ~/.jupyter
jupyter notebook --generate-config
# edit jupyter_notebook_config.py
c.NotebookApp.allow_origin = '*'
c.NotebookApp.allow_remote_access = True
# start jupyter notebook
jupyter notebook
s1 = '100'
s2 = '2012'
s3 = 'Washington University'
import base64
encoded = base64.b64encode((s1+s2+s3).encode())
import os
name = encoded.decode()+'.csv'
with open(name, 'wb') as f:
f.write(b'Hello World!')
import ipywidgets as widgets
widgets.HTML(
value='<a href = \"'+os.path.join('..', '..', 'files', name)+'\">Download</a>',
)
# 1. start jupyter notebook in the projec directory
jupyter notebook
# 2. open project ipynb file
# 3. click 'Voila' button