If you are not set up on using Python Flask, take the following steps to get started.
- Go to https://www.python.org/downloads/ to download the latest Python version
- Install Pip, the package installer for Python using the command python get-pip.py for Linux or MacOs and C:> py get-pip.py for Windows
- Install PostgreSQL database and create a database server
I provided my virtual environment if you want to run it exactly like I did, otherwise proceed with creating your virtual environment.
- To install virtual environment, use the command python3 -m venv .venv for MacOs and py -m venv .venv for Windows.
- If you face any error run the following command below then try the previous command again: -- virtualenv --system-site-packages -p python ./env -- Set-ExecutionPolicy Unrestricted -Scope Process
- Create a virtual environment python -m venv env
- Enter the environment using the command source env/bin/activate for Linux or MacOs and .\env\Scripts\activate
- After entering the virtual environment, install the dependencies by running pip install -r requirements.txt
- Initialise the database using the command flask db init
Run the migration file to update the database using the command flask db upgrade Run the application using python app.py
SignUp
Json Body:
{ "password": "password123", "email": "ayara.faith@gmail.com" }
{ "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTcxNjE5OTE3NSwianRpIjoiOThjZDM2NjgtOWEyZS00ODEzLWI2NTItZmUzYWM5MmRlZjQzIiwidHlwZSI6ImFjY2VzcyIsInN1YiI6MTgwMywibmJmIjoxNzE2MTk5MTc1LCJjc3JmIjoiOTUxZWFjZDgtYjk2Zi00M2Y3LWI1ZTQtYmE3MzdjYzc1MWEzIiwiZXhwIjoxNzE2MjAwMDc1fQ.zJU5K11f3tQWH3QoxITHjXEipawmsbe6UqJjaSgAfxs", "msg": "Welcome, your user ID is 1803. Kindly keep it somewhere save as this is required for login" }
Login
Json Body:
{ "user_id": "1803", "password": "password123" }
{ "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTcxNjIwMTc5NywianRpIjoiNzkzMmUzY2MtOWVmYy00NGY5LWE1OTItOTlhNDM4ZmY0MWJmIiwidHlwZSI6ImFjY2VzcyIsInN1YiI6IjE4MDMiLCJuYmYiOjE3MTYyMDE3OTcsImNzcmYiOiI5NDA0NDM4Yy0zNzQyLTQ1ODctOWIzMi1lNmY4OTc5YTc0YWUiLCJleHAiOjE3MTYyMDI2OTd9.WHBWDXNLRPzYDKxPvRUUmxlyNm6rO5vBpRFXzFg4AGY" }
{ "msg": "Welcome, create new tasks" }
Json Body:
{ "task_title": "Test Task", "task": "Complete this assessment", "due_date": "20-05-2024" }
{ "msg": "Task added succesfully" }
{ "msg": { "id": 1236, "task": "Test Task" } }
{ "msg": { "due_date": "20-05-2024", "task": "Complete this assessment", "title": "Test Task" } }
Json Body:
{ "task": "New Task", "due_date": "21-05-2024" }
{ "msg": "Task 1236 updated successfully" }
{ "msg": "Task 1236 deleted successfully" }