https://github.com/healeycodes/talking-between-python-and-js
Talking to Python from JavaScript (and Back Again!)
https://github.com/healeycodes/talking-between-python-and-js
Last synced: 11 months ago
JSON representation
Talking to Python from JavaScript (and Back Again!)
- Host: GitHub
- URL: https://github.com/healeycodes/talking-between-python-and-js
- Owner: healeycodes
- License: mit
- Created: 2019-04-11T10:23:40.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-09-21T12:06:30.000Z (over 5 years ago)
- Last Synced: 2025-05-05T21:11:54.480Z (11 months ago)
- Language: Python
- Homepage: https://healeycodes.com/javascript/python/beginners/webdev/2019/04/11/talking-between-languages.html
- Size: 30.3 KB
- Stars: 20
- Watchers: 1
- Forks: 28
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Talking to Python from JavaScript (and Back Again!)
This repository contains the tutorial code for my article on communicating between Python and JavaScript.

### 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](http://flask.pocoo.org/docs/1.0/cli/), 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.