swat4stats
swat4stats copied to clipboard
Source code to swat4stats.com backend
swat4stats.com backend
swat4stats.com is a full-featured player and server statistics service for SWAT 4.
This repository contains the source code for the backend of swat4stats.com.
You might also be interested in other projects that make up swat4stats.com:
- swat4stats.com - the web frontend of swat4stats.com
- swat4master - the master server service that provides the in-game server list infrastructure
Public API
swat4stats.com offers a public API for SWAT 4 game servers. If you run a server, the API allows you to enable stat tracking for your server, display leaderboards in-game, and even provide an admin interface for player identification.
For details, please refer to the Server API documentation.
Getting started
Firstly, you'll want to set up your own configuration using a .env file:
cp .env.example .env
The development server is set to work with the default variables out of the box. However, if needed, you can modify these variables later for a more personalized setup.
Run the development server stack:
docker compose up
This will start the development server on port 8000.
PostgreSQL and Redis instances that come with the development stack use the ports 5432 and 6379, respectively. These are exposed on your machine as well.
Apply the migrations:
docker compose exec runserver python manage.py migrate
If you wish, you can also set up a user with this command:
docker compose exec runserver python manage.py createuser your-cool-username [email protected] --password=strong --superuser
Once done, you'll be able to access the development server at localhost:8000
.
For example:
⚠️ Important: The database container running with the dev server is not persistent. When you stop the development stack, the data goes away.
💡 If you want your changes to stick around, consider running a separate PostgreSQL instance.
You can then adjust the SETTINGS_DB_*
variables accordingly.
Testing
⚠️ For the test suite to work, it needs both PostgreSQL and Redis. Ensure the development stack is up and running.
Running the test suite is as straightforward as:
pytest
Contributing
Spotted a bug, a typo, or something else that you are willing to improve? Contributions are welcome! Please check out the contribution guidelines.
License
Released under the MIT License.