Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/keller-mark/protobuf-py-to-js
Testing usage of protobuf for sending data from python server to javascript client
https://github.com/keller-mark/protobuf-py-to-js
Last synced: about 2 months ago
JSON representation
Testing usage of protobuf for sending data from python server to javascript client
- Host: GitHub
- URL: https://github.com/keller-mark/protobuf-py-to-js
- Owner: keller-mark
- Created: 2019-08-06T17:25:47.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-06-02T21:11:17.000Z (over 2 years ago)
- Last Synced: 2024-10-12T15:17:39.680Z (3 months ago)
- Language: HTML
- Size: 10.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## protobuf python-to-js demo
Serializing data in python and deserializing in the browser using [protobuf](https://developers.google.com/protocol-buffers/) and [protobufjs](https://www.npmjs.com/package/protobufjs).
### How it works
- Docker container compiles `.proto` definitions to both Python output and JSON output
- Flask server serializes data according to the Python class compiled from the `.proto` file
- Flask server serves `index.html` page that does the following:
- load the JSON object compiled from the `.proto` file
- fetch serialized data from Flask at `/data` endpoint
- deserialize and display on the page### Run the demo
```sh
# Compile the message format located at io/src/addressbook.proto
docker build -t protoc .
docker run -v $(pwd)/io:/proto/io protoc addressbook.proto
# Install js dependencies
npm install
# Install python dependencies
conda env create -f environment.yml
conda activate protobuf-demo-env
# Start python server
python main.py
```Open http://localhost:8000.