Giter Site home page Giter Site logo

Comments (6)

mahendrapaipuri avatar mahendrapaipuri commented on June 2, 2024 1

Hello,
I know this is a old issue but I am facing a very similar situation with a web server that serves static files. So, I have a web server, say myapp, that I would like to proxy using Jupyter server proxy. I have integrated it into JupyterLab and I can access it at http://localhost:8888/myapp URL. The landing page of myapp has say following content:

<H2>Create new session:</H2>
<FORM action="/session/new.cgi" METHOD=POST>
<INPUT NAME="NEWNAME" VALUE="Session_name">
<INPUT TYPE=SUBMIT VALUE="Create">
<br>
</FORM>

that serves static files. When I click submit on the page, I am being redirected to http://localhost:8888/session/new.cgi and end up with 404 error. If I manually navigate to http://localhost:8888/myapp/session/new.cgi I can access the page without any issues. I have tried using absolute_url, rewrite_response without much luck. Is it possible to achieve what I am trying here? If so, any pointer would be appreciated!

Cheers!!

from jupyter-server-proxy.

 avatar commented on June 2, 2024

I noticed absolute_url in the documentation and wanted to try it. From the documentation, it seems there are two ways to specify the configuration, i.e., traitlets and python packages. I need some help getting either one of those working. Here is my code for python package (I picked the code given in the documentation and tweaked just the command section):

  1. Put the following code in openrefine.py
def setup_openrefine():
  return {
    'command': ['python', '-m', 'http.server', '8080']
  }
  1. Created the following setup.py file:
import setuptools

setuptools.setup(
  name="jupyter-openrefine-server",
  # py_modules rather than packages, since we only have 1 file
  py_modules=['openrefine'],
  entry_points={
      'jupyter_serverproxy_servers': [
          # name = packagename:function_name
          'openrefine = openrefine:setup_openrefine',
      ]
  },
  install_requires=['jupyter-server-proxy'],
)
  1. Executed pip install . in the folder.

  2. Tried to browse http://www.tld.com/user/johndoe/proxy/8080/ and http://www.tld.com/user/johndoe/openrefine without any success. ps -aux does not show the process running.

What am I missing?

from jupyter-server-proxy.

manics avatar manics commented on June 2, 2024

If you're just getting started it's probably easier to use a configuration file instead of using a Python package which is useful when you've got a working application you want to distribute to others. Have you tried the example in point 4 absolute_url of Server Process options? Put

c.ServerProxy.servers = {
  'test-server': {
    'command': ['python3', '-m', 'http.server', '{port}'],
    'absolute_url': False
  }
}

in ~/jupyter_notebook_config.py

from jupyter-server-proxy.

 avatar commented on June 2, 2024

I tried the traitlets option as well:

  1. put the following code in ~/.jupyter/jupyter_notebook_config.py
c.ServerProxy.servers = {
  'test-server': {
    'command': ['python3', '-m', 'http.server', '{port}'],
    'absolute_url': False
  }
}
  1. browsed to http://www.tld.com/user/johndoe/test-server and also checked ps -aux. But don't see the command running.

I think I am missing a step to load the configuration (or python package) to trigger the command. Also, I am not sure if the endpoints I am browsing to are correct.

from jupyter-server-proxy.

manics avatar manics commented on June 2, 2024

The first example should take effect as soon as you restart you notebook. http://www.tld.com/user/johndoe/test-server looks like the correct URL, can you restart your notebook with debug logging?

from jupyter-server-proxy.

 avatar commented on June 2, 2024

I am running jupyterhub environment that spawns docker instance of notebook servers as a user logs in; I think that instance keeps running even when the client browser is terminated. Do I need to restart the notebook instance in the backend? Is there a way to reload the jupyter config without needing the backend access to restart the notebook. Does python package option also require restart?

from jupyter-server-proxy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.