0

I am using a Jupyterhub deployment with DockerSpawner. When I enter a spawned container, I have the following URL pattern:

https://<hostname>/user/<user-name>/lab?

I would like to get the value of <user-name> within the spawned notebook container. Is there any possibility to either access it or forward it from Jupyterhub into the container?

Thank you, Max

Max
  • 560
  • 1
  • 9
  • 25
  • There might be a way to pass it from jupyterhub container or get it somehow, but in my recent project i got it from javascript. – saurssaurav Feb 20 '19 at 06:42
  • You got it from Javascript within the spawned container? If so, can you share how you did it? – Max Feb 21 '19 at 12:42
  • yes. So, as you know all the spawned container are just a simple jupyter-notebook containing all the pages ( https://github.com/jupyter/notebook/tree/master/notebook/templates ). All I did was add a script to any template or page.html to add script to all templates. And made a new image with customize template. But my purpose of getting user-name was just to show a user-name in top of header and pass it to backend server. – saurssaurav Feb 24 '19 at 06:24

1 Answers1

1

Jupyterhub gives you an option to insert username through {username} command. If it doesn't work for you, you can try to write the next function:

def pre_spawn_hook(spawner):
    username = spawner.user.name
    ...