A recreation of Code::Stats in Python
Trying to install Code::Stats on my server resulted in many errors. The setup process was quite complicated and having no experience with Elixir did not help the situation.
Looking at the API docs, I decided to create my own implementation of Code::Stats in a language I knew better: Python. So I implemented a very simple Django API as a backend for Code::Stats plugins.
Should work with Python 3.8 or newer.
Tested on Python 3.11. It might also work with older Python versions. Feel free to try one and give me feedback on it!
Older versions of Django newer than 4.0 will also work.
- Clone the repository
git clone https://github.com/hex-developer/code-stats.py.git
-
cd code-stats.py/
- Install dependencies
pip3 install -r requirements.txt
- Setup the database
python3 manage.py makemigrations api python3 manage.py migrate python3 manage.py createsuperuser
- Run the server
Keep in mind that you can change the port
python3 manage.py runserver 0.0.0.0:8000
- Log in to the admin interface and set it up according to your needs
- Navigate to the /admin url at the address you are hosting your server.
Example: http://127.0.0.1:8000/admin - Log in with the username and password you used when setting up the database
- Create a machine with the name you want and copy your token. You can do this as many times as you want to.
- Log out
- Navigate to the /admin url at the address you are hosting your server.
- Setup your plugins with the following information:
- The token for your machine
- Your username
- The address of your server with /api: http://127.0.0.1:8000/api
You are now ready to use your server!
Make sure you set DEBUG=FALSE in settings.py and generate a secure secret key. It is recommended to serve this over https
For a complete guide see this post on realpython.com
All contributions are welcome!
See CONTRIBUTING.md for more details
Before opening an issue, make sure you have tested the problem with Python 3.11 and Django 4.1.7 installed, because you might have outdated versions.
You can find plugins from the official Code::Stats website here. Also I recommend the bash plugin here
- Frontend
- Dates in API Response