Closed straaljager closed 1 year ago
What follows is a bit of a guess, but I believe that using Transcrypt is going to require persisting the Python code locally, running Transcrypt as an external process (perhaps with the Python subprocess
module), and then sending the generated JS code back to the client.
Looking at the live turtle site, there is a URL route (http://www.transcrypt.org/compile) that accepts Python code in a POST request and then returns the name of a generated JS file that can then be loaded into the browser. If you were to dig around, you would find that the Python code is persisted to http://www.transcrypt.org/live/user/ then the JS file generated by Transcrypt is sent back to the client from http://www.transcrypt.org/live/user/__target__/
What is happening on the server is an automated way of running Transcrypt just as you would from a command line once the Python code is persisted locally.
Thanks a lot @JennaSys. That really helped my understanding of the client-server process. I will try to replicate this behaviour on a local machine.
Closing since no further comments.
I would like to create an online computer graphics course with Python, where users can write code in the browser, have it compiled to Javascript by a server and see the results on a canvas (very similar to the Transcrypt Turtle demo: http://www.transcrypt.org/live/turtle_site/turtle_site.html).
I'm struggling with setting up a local server to run the Transcrypt compilation and serve the results back to the browser. I could not find anything on this topic in the docs. Is there a minimal example somewhere on how to achieve this?