All Projects → healeycodes → talking-between-python-and-js

healeycodes / talking-between-python-and-js

Licence: MIT License
Talking to Python from JavaScript (and Back Again!)

Programming Languages

python
139335 projects - #7 most used programming language
HTML
75241 projects
javascript
184084 projects - #8 most used programming language

Talking to Python from JavaScript (and Back Again!)

This repository contains the tutorial code for my article on communicating between Python and JavaScript.


Desktop


Via JSON

A Flask web app with two routes. /test which serves a page with JavaScript that uses the Fetch API to GET JSON data from /hello, and then POSTs JSON data, also to /hello. Everything is logged to console.

Any issues with launching the Flask app should seek these docs, and the Flask home page for general installation instructions.


Via processes

There's also some files that demonstrate how processes can communicate via the stdout. Data is reported by a spawn process which is caught and collected. This is displayed in Python and Node.js. sensor.js, sensor.py, temperature-listener.js, temperature-listener.py. With the Node.js parent process, events are used. For the Python parent process we use a simple buffer and check for the newline char.


Hopefully this repository (combined with the article) will answer some beginner questions about how different languages 'talk' to each other! I'm accepting any PRs that bring further clarity or fix errors.


MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].