A backend API built using Python Flask and MongoDB for the database. This API can be consumed using the console application with setup predefined commands.
- Python 3.7+
- Pip
- MongoDB
- Redis
- instance running on localhost port 6379
-
Clone this repository and cd to the folder
git clone https://github.com/hawkinswinja/MiniBloggingApp-test.git cd MiniBloggingApp-test
-
Create a virtual environment and activate it:
python -m venv blog source venv/bin/activate # On Windows, use venv\Scripts\activate
-
Install the required packages
pip install -r requirements.txt
-
Create an
.env
file with the following contentMONGODB_URI='' MONGODB_DB='' URL='' # http://127.0.0.1:5000 (Flask app URL)
-
Setup the database and Redis:
- MongoDB should be configured based on your
.env
file. - Ensure Redis points to
localhost
and port6379
.- You can change it inside the
routes/__init__.py
file if needed.
- You can change it inside the
- MongoDB should be configured based on your
-
Run the Flask app
flask run
-
A success message on url
http://127.0.0.1:5000/status
indicates success -
Access the documentation from the endpoint:
http://127.0.0.1:5000/apidocs
- Alternatively you can leverage the docker compose script which starts up the different services at once.
- cd into the repo directory
- Run the below command to spin up the application
docker compose up -d
- Run the console.py script in another tab (no need to use another tab if using docker compose)
- Type help to display commands and their usage
- CTRL + C is a keyboard interrupt and ends the program
- Upon login store the returned token as you'll need to pass it as an arg for most requests.
- Example of logging out the current user with token 12345678
blog-app> logout 12345678
-
python -m unittest discover tests