Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to integrate Python and JavaScript?

Is it possible to integrate Python and JavaScript? For example, imagine you wanted to be able to define classes in JavaScript and use them from Python (or vice versa). If so, what's the best way? I'm interested not only if this is possible but if anyone has done it within a "serious" project or product.

I'm guessing it would be possible using Jython and Rhino, for one example, but I'm curious whether or not anyone's ever actually done this, and if there are solutions for other platforms (especially CPython).

like image 234
Jacob Gabrielson Avatar asked Mar 25 '09 21:03

Jacob Gabrielson


People also ask

Can I integrate Python with JavaScript?

JS2PY works by translating JavaScript directly into Python. It indicates that you may run JS directly from Python code without installing large external engines like V8. To use the module it first has to be installed into the system, since it is not built-in. To use the module it has to be imported.

Can you use JavaScript for frontend and Python for backend?

The visual aspects of the website that can be seen and experienced by users are frontend. On the other hand, everything that happens in the background can be attributed to the backend. Languages used for the front end are HTML, CSS, JavaScript while those used for the backend include Java, Ruby, Python, . Net.

How pass data from JavaScript to Python?

To pass variables from Python Flask to JavaScript, we can call render_template with the data argument with the dictionary of data we want to pass to the template. to call render_template with the template file name and the data set to the data dict with the data we want to pass to the template.


1 Answers

How about pyjs?

From the above website:

pyjs is a Rich Internet Application (RIA) Development Platform for both Web and Desktop. With pyjs you can write your JavaScript-powered web applications entirely in Python.

like image 150
Stephen Simmons Avatar answered Sep 22 '22 16:09

Stephen Simmons