Some basic things you need to know about this backend is my way of thinking and implementing the backend. I came up with the idea that only the admins are allowed to make changes in the library system. So, I defined the login features for the admins.
I have used MySQL database. So, let's set up the database first.
Your database is all set. Now we need to connect the database with the flask application. Below are the steps:
- Clone and open the repository in IDE
- Dowload and install python, if you don't have installed
- Setup the virtual environment
- Install the requirements.txt using command:
pip install -r requirements.txt- Create ".env" file, in directory where main.py file is located, with the following parameters:
host = localhost
user = root
password = ""
database = your_database_name
secret_key = create_secret_key as said below:
Open the command prompt and type the command
python -c "import secrets; print(secrets.token_hex(16))"- Run the backend using the command:
python main.py
You can check the APIs here for each of their purposes. If you want to run these APIs you have to do it locally. Before running these APIs here are few things that you need to take care of:
- First of all, one admin account is already created in the backend with which you can create the multiple admins. Login credentials are as:
Email: admin@gmail.com
Password: admin@123 - Before using these APIs you need to login with the above credentials which will in return provide you token
- The validation time of token is 4 hours. After 4 hours, you need to regenerate the token.
- And for each of the APIs you need to send token while calling.