Created
June 21, 2016 21:25
-
-
Save teh/9600133d17850111026f0c0a51c6fa40 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{%- extends 'full.tpl' -%} | |
{%- block input_group -%} | |
{%- endblock input_group -%} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://nbconvert.readthedocs.io/en/latest/execute_api.html | |
# http://nbconvert.readthedocs.io/en/latest/nbconvert_library.html | |
import flask | |
import nbformat | |
from nbconvert.preprocessors import ExecutePreprocessor, Preprocessor | |
from nbconvert import HTMLExporter | |
from traitlets.config import Config | |
ep = ExecutePreprocessor(timeout=600, kernel_name='python3') | |
c = Config() | |
c.Exporter.template_file = 'cell' | |
c.HTMLExporter.preprocessors = [ep] | |
app = flask.Flask(__name__) | |
@app.route('/') | |
def render(): | |
notebook_filename = '/tmp/testnotebook.ipynb' | |
with open(notebook_filename) as f: | |
nb = nbformat.read(f, as_version=4) | |
html_exporter = HTMLExporter(config=c) | |
html_exporter.preprocessors | |
body, resources = html_exporter.from_notebook_node(nb) | |
return body | |
if __name__ == '__main__': | |
app.run(port=8082, debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment