Coder Social home page Coder Social logo

jpchauvel / chat Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 52 KB

A small chat app built using FastAPI, uvicorn and redis.pubsub. It also contains a small CLI that connects to the API with the websockets package.

License: Creative Commons Zero v1.0 Universal

Dockerfile 9.49% Python 90.51%

chat's Introduction

Generic chat application built with Redis PubSub and FastAPI

This application has a single global room where all connected "users" can send and receive messages.

You can build a web-based frontend using the Websockets API. The message is basically a JSON object with the following form:

{
    "nickname": "Joe Doe",
    "message": "A message"
}

NOTE: It does not echo the sender's message.

I've included a test CLI program called testchat.py. Its usage is pretty straightforward: you just have to provide a nickname and then a message. After that it waits for other users' messages to arrive. Once the messages are received, the prompt to send a new message is presented once again. Looping endlessly.

Running the server

To run the server you just need docker (docker compose) installed in your machine and the run the following command:

docker-compose -f docker-compose.yml up

Running the test script

In this case you have to first make sure you have Python and Poetry installed in your system.

I will not give you details on how to install Python in your system, for that you can go to https://www.python.org.

To install poetry, just run the following command:

pip install -U poetry

Then, install all the test script dependencies, just so:

poetry install

After that you're good to run the test script!

poetry run ./testchat.py

chat's People

Contributors

jpchauvel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.