Integrate JupyterHub into Web App

I’m working on a web app to orchestrate various Data Science services centered around a project workflow. I’d like to be able to integrate jupyterbug into this app and make data from the app available to the notebook when it starts up.

this particular app us using the Pyramid framework, but I think the help I’m looking for is pretty equally applicable to a Django or Flask app.

Basically, I have, say, projects, and projects have datasets that can be files or sqlalchemy queries. There are all kinds of other things that can also be associated with the project, like a location to save files (transformed datasets, jupyer notebooks, etc.) and other session data that’s relevant to the user and project and settings.

I’m aware that you can do this:

But that’s a totally isolated thing, and I’m really unsure how I would pass variables to the instance like that.

Does anyone have any thoughts or hints about how I might be able to get a tighter integration into my app than just embedding?

I would have my own webserver respond to get parameters, formulate a notebook that has the proper code for loading the relevant data, spawn the notebook, and then redirect the user to that notebook