diff options
Diffstat (limited to 'tbc')
-rw-r--r-- | tbc/views.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tbc/views.py b/tbc/views.py index d2ff195..e4a818f 100644 --- a/tbc/views.py +++ b/tbc/views.py @@ -507,3 +507,25 @@ def BrowseBooks(request): context['items'] = book_images context['category'] = category return render_to_response('tbc/browse-books.html', context) + + +def ConvertNotebook(request, notebook_path=None): + path = os.path.abspath(os.path.dirname(__file__)) + path = path+"/static/uploads/" + path = path+notebook_path + notebook_name = path.split("/")[-1:] + notebook_name = notebook_name[0].split(".")[0] + path = path.split("/")[0:-1] + path = "/".join(path)+"/" + os.chdir(path) + try: + template = path.split("/")[8:] + template = "/".join(template)+notebook_name+".html" + print ("try") + return render_to_response(template, {}) + except: + os.popen("ipython nbconvert --to html "+path+notebook_name+".ipynb") + template = path.split("/")[8:] + template = "/".join(template)+notebook_name+".html" + print ("except") + return render_to_response(template, {}) |