Skip to content


Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Connect Four Master Server

A REST API to connect all the Connect Four players together from all over the world.


  • Web-based game browser interface with filtering capabilities
    • Ability to view every single game ever played
    • IP / name / version / status
    • Which player has won if the game is finished
    • When the game has been created, started and finished
  • REST API used by the Connect Four game itself to advertise hosts and keep online game's data up-to-date


  • Should work on any Python 3.x version. Feel free to test with another Python version and give me feedback
  • A uWSGI-capable web server (optional, but recommended)


  1. Clone this repo somewhere
  2. pip install -r requirements.txt
  3. export (Windows users: set
  4. flask create_database (WARNING: don't re-run this command unless you want to start from scratch, it will wipe out all the data)


Copy the file to and fill in the configuration parameters.

Available configuration parameters are:

  • SECRET_KEY Set this to a complex random value
  • DEBUG Enable/disable debug mode

More informations on the three above can be found here.

  • GAMES_TTL Grace time (or time to live), in minutes, of the games who don't have the FINISHED status

I'll let you search yourself about how to configure a web server along uWSGI.


  • Standalone

Run the internal web server, which will be accessible at http://localhost:8080:


Edit this file and change the interface/port as needed.

  • uWSGI

The uWSGI file you'll have to set in your uWSGI configuration is The callable is app.

  • Others

You'll probably have to hack with this application to make it work with one of the solutions described here. Send me a pull request if you make it work.

A Flask command (flask clean) is used to clean the database. It removes old games with a status different from FINISHED which have their latest ping older than now minus 5 minutes (by default). It should be ran by a Cron or some task scheduler i.e every one minute, but this isn't mandatory.

API docs

Please navigate here for the full docs.

How it works

This project is mainly powered by Flask (Python) and Flask-RESTful using a small SQLite database to persist data. HTTP requests are used to maintain the games pool up-to-date.

For more information, I suggest you do dive into the code starting with the file.


  • This project uses GeoLite2 data created by MaxMind, available from
  • Some good parts of the OpenRA Master Server inspired me
  • Connect Four™ is a trademark of Milton Bradley / Hasbro. This project isn't supported nor endorsed by Milton Bradley / Hasbro

End words

If you have questions or problems, you can submit an issue.

You can also submit pull requests. It's open-source man!


A REST API to connect all the Connect Four players together from all over the world