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)
- Clone this repo somewhere
pip install -r requirements.txt
export FLASK_APP=cfms.py
(Windows users:set FLASK_APP=cfms.py
)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 config.example.py
file to config.py
and fill in the configuration parameters.
Available configuration parameters are:
SECRET_KEY
Set this to a complex random valueDEBUG
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 theFINISHED
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
:
python local.py
Edit this file and change the interface/port as needed.
- uWSGI
The uWSGI file you'll have to set in your uWSGI configuration is uwsgi.py
. 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.
Please navigate here for the full docs.
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 cfms.py
file.
- This project uses GeoLite2 data created by MaxMind, available from www.maxmind.com
- 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
If you have questions or problems, you can submit an issue.
You can also submit pull requests. It's open-source man!