-1

Does IPython have a web server mode to run code submitted through REST APIs? I couldn't find any info on this. Are there any alternatives to this?

My use case is similar to an online interpreter, but I want the code to run on the machine where the server is running (to be able to import packages and modules, and use file that are in the server's PATH).

If not, how do I get started on building one? The places where I need help are:

  • How to execute the python code I get through the API in the server? Do I just use exec or is there a better way to do this?
  • How do I isolate different scripts? If two scripts are running in the server, they should not interfere with each other (for example, if both scripts have a variable with the same name, they should be isolated and should not be considered as the same variable which not be the case if I use exec).
BBloggsbott
  • 195
  • 2
  • 12
  • I don't know if you've also seen [Connect to remote python kernel from python code](https://stackoverflow.com/questions/59977601/connect-to-remote-python-kernel-from-python-code/60094686#60094686) and links therein or the discussion in relation to [here](https://twitter.com/davidbrochart/status/1536687607022866433)? – Wayne May 26 '23 at 15:21

1 Answers1

0

The Jupyter server (https://jupyter-notebook.readthedocs.io/en/stable/public_server.html) does what you want, by sharing Notebooks. You can configure a Jupyter server to accept incoming connections, protected with a password. It has an REST-API, if you need it: https://jupyter-server.readthedocs.io/en/latest/developers/rest-api.html

Be aware of security problems, a good idea might be to run the server in a container to prevent access to your complete system and limit access to VPN connections and use SSL. If someone outside has control over your Jupyter-Server, they have a convenient interface to compromise your whole system.

oekopez
  • 1,080
  • 1
  • 11
  • 19