diff --git a/IPython/html/services/notebooks/handlers.py b/IPython/html/services/notebooks/handlers.py
index f5d659b..54e7d2b 100644
--- a/IPython/html/services/notebooks/handlers.py
+++ b/IPython/html/services/notebooks/handlers.py
@@ -69,17 +69,22 @@ class NotebookHandler(IPythonHandler):
self.finish(jsonapi.dumps(notebooks))
else:
format = self.get_argument('format', default='json')
+ download = self.get_argument('download', default='False')
model = nbm.notebook_model(name,path)
last_mod, representation, name = nbm.get_notebook(name, path, format)
-
- if format == u'json':
- self.set_header('Content-Type', 'application/json')
- self.set_header('Content-Disposition','attachment; filename="%s.ipynb"' % name)
- elif format == u'py':
- self.set_header('Content-Type', 'application/x-python')
- self.set_header('Content-Disposition','attachment; filename="%s.py"' % name)
- #self.set_header('Last-Modified', last_mod)
- self.finish(jsonapi.dumps(model))
+ self.set_header('Last-Modified', last_mod)
+
+ if download == 'True':
+ if format == u'json':
+ self.set_header('Content-Type', 'application/json')
+ self.set_header('Content-Disposition','attachment; filename="%s.ipynb"' % name)
+ self.finish(representation)
+ elif format == u'py':
+ self.set_header('Content-Type', 'application/x-python')
+ self.set_header('Content-Disposition','attachment; filename="%s.py"' % name)
+ self.finish(representation)
+ else:
+ self.finish(jsonapi.dumps(model))
@web.authenticated
def patch(self, notebook_path):
diff --git a/IPython/html/static/notebook/js/menubar.js b/IPython/html/static/notebook/js/menubar.js
index dbe4108..419a789 100644
--- a/IPython/html/static/notebook/js/menubar.js
+++ b/IPython/html/static/notebook/js/menubar.js
@@ -91,14 +91,14 @@ var IPython = (function (IPython) {
});
this.element.find('#download_ipynb').click(function () {
var notebook_name = IPython.notebook.get_notebook_name();
- var url = that.baseProjectUrl() + 'api/notebooks/' +
- notebook_name + '?format=json';
+ var url = that.baseProjectUrl() + 'api/notebooks/' + that.notebookPath() +
+ notebook_name + '?format=json'+ '&download=True';
window.location.assign(url);
});
this.element.find('#download_py').click(function () {
var notebook_name = IPython.notebook.get_notebook_name();
- var url = that.baseProjectUrl() + 'api/notebooks/' +
- notebook_name + '?format=py';
+ var url = that.baseProjectUrl() + 'api/notebooks/' + that.notebookPath() +
+ notebook_name + '?format=py' + '&download=True';
window.location.assign(url);
});
this.element.find('#rename_notebook').click(function () {