Skip to content

A simple chat/messaging app demo using gRPC.

License

Notifications You must be signed in to change notification settings

Chun-Cheng/python-grpc-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python-grpc-demo

A simple chat/messaging app demo using gRPC.

demo screenshot

Prerequisites

  • Python>=3.12 installed
  • Poetry installed
  • Unix environment (need curses in Python)

How to run

  1. Install dependencies
    poetry install --no-root
  2. Activate Poetry environment
    eval $(poetry env activate)
  3. Add src to Python path (Change the path to yours)
    export PYTHONPATH=$PYTHONPATH:path/to/python-grpc-demo/src
  4. Start the server
    python src/server/server.py
  5. Open another shell and repeat step 1~3, then start the client
    python src/client/client.py

Update the protos

To generate a new version of protobuf code, setup the environment first:

poetry install --no-root --extras dev
eval $(poetry env activate)

Then, run the following command:

python scripts/generate.py

File structure

python-grpc-demo
├── protos/             # Protocol Buffers definition contents
├── scripts/            # useful commands
│   └── generate.py     # generate Python codes from protos/
├── src/                # source code
│   ├── proto_gen/      # generated codes from protos/
│   ├── client/
│   └── server/
├── pyproject.toml      # project and dependencies info and settings
└── ......

The app use SQLite to store data. If you want to clear the data, delete server.db and client.db.

About

A simple chat/messaging app demo using gRPC.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages