Jupyter Hub Link with Python Code Snippet

I’m looking for a way to link to a Littlest Jupyter Hub instance with a snippet of Python that gets incorporated into a new notebook file.

The nbgitpuller extension works great for content in a Git repo. I’m looking for a similar user experience for arbitrary Python snippets that aren’t in notebook file with a repo.

Does an extension exist for that?

Do you need it to be a plugin? Depending on the source of the Python snippet, this is a combination of a wget (or curl) command followed by a jupytext command. Python to a notebook is here as:

jupytext --to notebook notebook.py  

You can add in --execute to have the notebook run as well and control the output file name with the --output option.

That’s a great suggestion, but I’m specifically curious about sharing a snippet of Python not hosted anywhere. I’d like to be able to craft a link without any ahead-of-time preparation.

What about the discussion here? Any applicable tech there?
Or /hub/user-redirect?
Or just the now built-in “Copy Shareable Link”? The newer JupyterLab seems to allow that with Python files.

No, not at first glance, but thank you!

I’m looking for a way to pass a snippet of Python as a query parameter which gets converted into a Python notebook by Jupyter Hub. The idea is conceptually very similar to the nbgitpuller extension. To use that, query params including repo, branch, and others are passed to Jupyter Hub.