Creating a notebook ipynb file using notebook json which we get from a server

33 views
Skip to first unread message

anmi...@umich.edu

unread,
Dec 11, 2017, 11:01:34 AM12/11/17
to Project Jupyter
Hi,

I am working on this tree extension, which puts a button on the toolbar (see the attached file). On clicking the button, I fetch a notebook json from a server and store it in a javascript variable. I would like to create and open the notebook using the json received for the user to start working on. 

I am aware of the working in the contents.js file in the services folder, but not sure how I can create a file using what's available. 

Best,
Anant
Screenshot from 2017-12-11 11-00-53.png

Thomas Kluyver

unread,
Dec 11, 2017, 11:38:01 AM12/11/17
to Project Jupyter
It's probably easiest to create a file on the server side, then you just need to open a window with the right URL to view it.

To do this from the Javascript side, you'd need to get the data from the server and then send it straight back to be saved to a file.

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/b3330376-582d-4e90-9933-b5d740fbf8f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

anmi...@umich.edu

unread,
Dec 11, 2017, 11:54:23 AM12/11/17
to Project Jupyter
Hi, 

By the server, I meant a server which is running on an AWS lambda. The functionality that I want is to create a notebook using the json which I have received from the server. Think of it as a function which is used to create a new empty notebook. But in my case, I would like to create a notebook with a pre-filled notebook json I have. 

Is that making sense?

Best,
Anant


On Monday, December 11, 2017 at 11:38:01 AM UTC-5, takowl wrote:
It's probably easiest to create a file on the server side, then you just need to open a window with the right URL to view it.

To do this from the Javascript side, you'd need to get the data from the server and then send it straight back to be saved to a file.
On 11 December 2017 at 16:01, <anmi...@umich.edu> wrote:
Hi,

I am working on this tree extension, which puts a button on the toolbar (see the attached file). On clicking the button, I fetch a notebook json from a server and store it in a javascript variable. I would like to create and open the notebook using the json received for the user to start working on. 

I am aware of the working in the contents.js file in the services folder, but not sure how I can create a file using what's available. 

Best,
Anant

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.

anmi...@umich.edu

unread,
Dec 11, 2017, 1:01:25 PM12/11/17
to Project Jupyter
I think I need to use Contents API. 

Thomas Kluyver

unread,
Dec 12, 2017, 6:52:10 AM12/12/17
to Project Jupyter
Ah, I see - it's coming from a different server. In that case, you'll need to do something like this:

var nb_json = {"nbformat": 4, ...}
var model = {type: "notebook", content: nb_json}
Jupyter.contents.save("folder/filename.ipynb", model).then(function() {
    console.log("Saved notebook");
})

I haven't tested this, so it might need tweaking a bit.

Thomas

To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+unsubscribe@googlegroups.com.

To post to this group, send email to jup...@googlegroups.com.

Anant Mittal

unread,
Dec 12, 2017, 11:00:32 AM12/12/17
to jup...@googlegroups.com
Thank you, Thomas! This helped. 

--
You received this message because you are subscribed to a topic in the Google Groups "Project Jupyter" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jupyter/Vj7r-65opJ0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jupyter+unsubscribe@googlegroups.com.

To post to this group, send email to jup...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages