vpython / vpython-jupyter

3D visualization made easy
MIT License
138 stars 65 forks source link

Embedding Vpython7 in a web page #217

Open danx0r opened 2 years ago

danx0r commented 2 years ago

Hi -- New to VPython, in many ways it is my dream platform. The Jupyter integration is awesome, but I want to utilize the browser capabilities to embed VPython in a page. Note that I do not want to transpile into glowscript; I want to run a standard Python server and allow users to connect and have an interactive 3D experience.

I see that it is architected as a client-server app using websockets, running standard Python and opening a web browser on a random port on localhost. It seems to me there should be an easy way to run the server headless so to speak, and have it respond to http requests from a browser over a fixed port -- but I can't find any documentation or examples of this approach.

As a dirty POC, I hacked no_notebook.py to use a hard-coded port, and commented out the code that launches a browser. (This is a better dev experience already as the browser launch code does not play nicely with Ubuntu/gnome's multiple workspaces, but I digress...)

It seems a small step from here to serving on say port 5123, and wrapping nginx TLS around it so the browser can hit https://mysite and Bob's your uncle...

So -- I guess this is a feature request? I could probably pull together a PR on this - unless there is some obvious way to do it on the platform as it exists, but I get the feeling there has been more focus on the notebook implementation.

Any leads or suggestions greatly appreciated. And Thank You for contributing to the Open Source community!