I'm writing a server extension for jupyter lab and i can use ServerConnection.makeRequest() from #jupyterlab/services to send POST or GET to my custom URL in typescript.
Now i want to make some request from notebook to this URL by using library requests of python but i always get 403 error.
Is there any equivalent of ServerConnection.makeRequest() in jupyter lab python library to send request to server ?
Your request from within a notebook is most likely forbidden due to the xsrf check by the jupyter server. When you start jupyter server pass the parameter --NotebookApp.disable_check_xsrf=True in the command line to disable it. Or you need to handle passing the xsrf token. Note that disabling this check in an external-facing (production) system is not recommended.
You may also have to pass or suppress token. The token can be suppressed by passing --NotebookApp.token='' when you start the server.
Related
We have recently moved to a JupyterLab Server from another IDE. We are trying to get VS Code hooked up so that we can code in it rather. After much struggle, we got VS Code to connect to our remote JupyterLab server. On the status bar in the bottom, it shows
However, as soon as we connect to the JupyerLab server, all the 'run' buttons on screen disappears.
We are getting no support from our IT and have to figure it out ourselves.
A colleague suspects that it (VS Code) is not picking up the python kernel from the server. How do we go about selecting it? or pointing to it?
An additional question, how do we see and browse the folders on the JupyterLab server in VS Code?
Appreciate any assistance
I think the problem is that you didn't really connect to the remote server.
Install Remote-SSH extension. Then you can see the button on the bottom left. Click and you can connect to your service and view your folder.
You can read document about Remote-SSH for more details/
Connect to a remote Jupyter server.
According to the document about jupyter, you have to do the following steps:
Open the Kernel Picker button on the top right-hand side of the notebook (or run the Notebook: Select Notebook Kernel command from the Command Palette).
Select the Existing Jupyter Server option to connect to an existing Jupyter server.
To connect to an existing server for the first time, select Enter the URL of the running Jupyter server.
When prompted to Enter the URL of the running Jupyter server, provide the server's URI (hostname) with the authentication token included with a ?token= URL parameter. (If you start the server in the VS Code terminal with an authentication token enabled, the URL with the token typically appears in the terminal output from where you can copy it.) Alternatively, you can specify a username and password after providing the URI.
I'm trying to connect to a remote jupyter notebook.
Server-side actions:
I simply use jupyter notebook command that produces the following output:
http://localhost:8888/?token=c7a760ee5387de7d6a1cb797a0685a116621f8b3b5a1a5ba
I know that there's password authentication procedure as well. I set up the jupyter_notebook_config.py file. I changed the c.NotebookApp.password and c.NotebookApp.open_browser variables.
Client-side actions:
Since I'm using Putty I can copy/paste the HTTP address (with token) to a local browser. I get the following page:
Even though I'm using the token from the link (step 1) and password (step 2) I get the Invalid Credentials error.
There's a proxy server between the local machine and the server but I don't know how to account for that fact.
Update 11.10.2019
I decided to tweak some parameters in .jupyter/jupyter_notebook_config.py file. By sacrificing security I did away with token authentication by setting c.NotebookApp.token=''. I still get the Invalid credentials message.
jupyter_notebook_config.py which resides in .jupyter directory (in the home directory of the user) is created with jupyter notebook --generate-config. All of the options are commented out. You need to find c.NotebookApp.ip variable that must not be commented out and set its value to the IP of the server the Jupyter is running on. If you want to connect to that instance of Jupyter from another machine you need to find localhost:port webpage with a browser of your choosing. My answer assumes that you've forwarded the port you are using.
I deployed a bottle website on Azure but it shows 500 (internal error) and I can’t see the log. I refer to https://github.com/Microsoft/PTVS/wiki/Azure-Remote-Debugging to debug my project but it failed.
It shows the error message as below.
could not attach to python.exe process on Azure web site at testpybottleapp.azurewebsites.net.
Error retrieving websocket debug proxy information from web.config.
And when I try to open http://testpybottleapp.azurewebsites.net/ptvsd it said ptvsd not existed.
Have you considered using VorlonJS as well? It's a remote website debugger which may help in this case.
Alternatively, could you try grabbing a similar VM from VMDepot, uploading that, and seeing if you have the same issue? That could help us troubleshoot and understand if the issue lies in the VM itself, or one of the configuration settings.
If we want to use the remote debug on Azure for python website, we should set the publish mode as "debug". And then we should enable websocket.
Meanwhile I suggest you can try to use the debug=>Attach to Process and input wss://WSGI_PTVSD_SECRET#WEBSITE_NAME.azurewebsites.net/ptvsd. When the process (Python.exe) is shown,you can click the "Attach". Then you can open your website http://WEBSITE_NAME.azurewebsites.net in browser.
If you visit the URL like "http://mysite.azurewebsites.net/ptvsd" and get the "ptvsd not existed" error, Please double check these points:
You should publish your website as Debug mode not release mode.
Make sure the 'WSGI_PTVSD_SECRET' in local is same as the Azure website .
In order to access a Reviewboard server I need to disable the SSL verification, however, I can't seem to do this from Reviewboard's Python API.
I've added a 'DISABLE_SSL_VERFICATION = True' line to ~/.reviewboardrc. The rbt commands themselves find this file ok, but scripts using the Python API don't seem to know it exists.
I'm seeing this behavior on both Ubuntu and a Cygwin install under Windows.
Is there something I'm missing with setting my Reviewboard configuration? Is there another way to disable SSL verification with the Python API?
I wasn't able to disable ssl verification globally, but there is a way to disable it when creating the RBClient that then carries through to any operations performed using that client.
Originally I was creating my client as below:
client = RBClient('server_url')
To disable ssl verification I added a verify_ssl argument and set it to false:
client = RBClient('server_url', verify_ssl=False)
Use the option —disable-ssl-verification for all rbt commands.
For example to post to Review board using retools use the command below.
rbt post —disable-ssl-verification
The exact reason why this is required is because of the Python Library. If you are using a Python Library version greater than 2.7.9 you will need this additional option.
We have a web app that allows users to interactively discover web service data URLs. We would like to allow a discovered service URL to be sent to an Ipython Notebook, where data from the service could be extracted, analyzed and visualized in the notebook. Is that possible?
This topic : Connecting to a remote IPython instance
will show you how to execute python code from an app/script and return any "python objects" back to the notebook kernel.
Essentially what i will do in this case is to execute python code from the web app using the approach described before, note that for recent version of IPython (i use 3.0-dev) you should change :
from IPython.zmq.blockingkernelmanager import BlockingKernelManager
to :
from IPython.kernel import BlockingKernelClient
If your web-app can receive parameters in the url, you can construct the url+query from the notebook giving the connection info as one of the input parameters.
You can retrieve the connection ifo within the notebook using:
%connect_info