Football bet rest/graphql server
Project description
Yak-toto
Requisites
- Ubuntu 22.04
- Python 3.10.4
- MySQL 8.0.30
How to build the project
Database
Install and start mysql server on port 3306. Add a database named yak_toto. In root folder, create a dotenv file named .flaskenv and fill your MySQL user name, password and database. When backend start, this configuration is automaticaly loaded.
MYSQL_USER_NAME=my_user_name
MYSQL_PASSWORD=my_password
MYSQL_DB=my_database_name
You can also set MySQL port by adding MYSQL_PORT=my_port to .flaskenv file. If not set, it will be 3306 by default.
Backend
Run your project in a Python env is highly recommend. You can use venv with the following command:
python3 -m venv <my_env_name>
Then activate it with:
source <my_env_name>/bin/activate
Fetch all packages using poetry with the following command:
poetry install
Before starting the backend, add JWT_SECRET_KEY in .flaskenv same as the MySQL user name and password. As
login system is using JSON Web Token, a secret key is required. To generate one, you can use the python built-in secrets module.
>>> import secrets
>>> secrets.token_hex(16)
'9292f79e10ed7ed03ffad66d196217c4'
JWT_SECRET_KEY=9292f79e10ed7ed03ffad66d196217c4
Also, automatic backup can be done through yak_server/cli/backup_database script and is able to send notification to Telegram bot. It can be run using flask db backup. To do so, please add a Telegram bot token and chat id to .flaskenv.
BOT_TOKEN=my_bot_token
CHAT_ID=my_chat_id
If the variables are not set, no telegram will be send.
Finally, flask needs some configuration to start. Please add FLASK_APP=yak_server variable to indicate main location. Last thing, for development environment, debug needs to be activated with a addditional environment variable:
FLASK_DEBUG=1
And then start backend with:
flask run
Data initialization
To run local testing, you can use the script create_database.py, initialize_database.py and create_admin.py located in yak_server/cli folder. To select, set COMPETITION environment variable in .flaskenv. It will read data from yak_server/data/{COMPETITION}/.
Testing
To set up test, please add a MySQL database named yak_toto_test. It will contain all the records created during unit tests. This database is cleaned everytime you run test. That's why a different database is created to avoid deleting records you use for your local testing.
Yak-server is using pytest to run tests and can run them using poetry run pytest command into root folder.
To generate xml report, run pytest --cov-report=xml --cov=yak_server tests/ -vv.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yak_server-0.3.2.tar.gz.
File metadata
- Download URL: yak_server-0.3.2.tar.gz
- Upload date:
- Size: 24.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa4604ebd814b006d81a434c43642a19bdff8261325fc0863911c72a3d23147f
|
|
| MD5 |
ba63e51e3782fb3bb4daecad895f8bec
|
|
| BLAKE2b-256 |
b066124e53c8a7586794f991c4d9240df13b6e9984f31c0003c41602129a8098
|
File details
Details for the file yak_server-0.3.2-py3-none-any.whl.
File metadata
- Download URL: yak_server-0.3.2-py3-none-any.whl
- Upload date:
- Size: 33.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5e376618e6cca2d87db6f4b3ff8ed3c77965a19a62d4e4dbffae0a5c713771c
|
|
| MD5 |
a8ab3ce46c843c4d28f7c0a513026fb0
|
|
| BLAKE2b-256 |
d2cdea4ac1b208c7df288e3dcd3588c031fbb882bad8effe907b648d193b8b56
|