This application helps you log and catalog all the stuff you want to accomplish before you expire.
Flask api's endpoints.
Endpoint | Functionality |
---|---|
POST /auth/login |
Logs a user in |
POST /auth/register |
Register a user |
POST /bucketlists |
Create a new bucket list |
GET /bucketlists |
List all the created bucket lists |
GET /bucketlists/<bucketlists_id> |
Get single bucket list |
PUT /bucketlists/<bucketlists_id> |
Update this bucket list |
DELETE /bucketlists/<bucketlists_id> |
Delete this single bucket list |
POST /bucketlists/<bucketlists_id>/items |
Create a new item in bucket list |
PUT /bucketlists/<bucketlists_id>/items/<item_id> |
Update a bucket list item |
DELETE /bucketlists/<bucketlists_id>/items/<item_id> |
Delete an item in a bucket list |
Endpoint | Functionality |
---|---|
SEARCH /bucketlists?q=abc |
Enter a search parameter |
LIMIT /bucketlists?limit=2 |
Number of items per page(default is 20) |
Methods | Description |
---|---|
GET | Retrieves a resource(s) |
POST | Creates a new resource |
PUT | Updates an existing resource |
DELETE | Deletes an existing resource |
SEARCH | Searches for an existing resource |
-
Clone this repository.
-
via HTTPS
-
via SSH
- [email protected]:gacheruevans/Flask-Bucket-List-API.git
-
-
Navigate to project directory.
cd Flask-Bucket-List
-
Create a virtual environment.
mkvirtualenv env
-
Start virtual env workon env
when selecting the virtual environment, you can pick any name that suits you for now you will be using env
-
Set up the environment requirements.
pip install -r requirements.txt
-
Initialize, migrate and update the database.
python run.py db init python run.py db migrate python run.py db upgrade
-
Test the application can run in various python packages, by running the following command.
tox
-
Run Project tests, by running the following command.
pytest -v
-
Test the application coverage by running the following command.
coverage report --omit=run.py
-
Run the server.
python run.py runserver
Access the endpoints using your preferred client e.g Postman
-
GET http://127.0.0.1:5000/api/v1/auth/login will give you the following message. body
{ "message": "Welcome to the BucketList API. Register a new user by sending a POST request to /auth/register. Login by sending a POST request to /auth/login to get started." }
-
POST http://127.0.0.1:5000/api/v1/auth/register will prompt you to register a new user, providing username, email and password
body
{ "username":"Evans", "email":"[email protected]", "password":"evans123" }
response
{ "message": "Evans created successfully" }
-
POST http://127.0.0.1:5000/api/v1/auth/login will login user and generate a token.
body
{ "username":"Evans", "password":"evans123" }
response
{ "message": "Welcome Evans", "token": "Generated Token" }
-
POST http://127.0.0.1:5000/api/v1/bucketlists create a new bucket list
header
Authorization : Generated Token
body
{ "name":"January Activities" }
response
{ "message": "January Activities created bucketlist successfully" }
-
GET http://127.0.0.1:5000/api/v1/bucketlists displays all of the users bucket lists.
header
Authorization : Generated Token
response
{ "bucketlists": [ { "creator": "EVANS", "date_created": "Sun, 15 Jan 2017 08:17:36 GMT", "date_modified": null, "id": 1, "items": [], "name": "January Activities" } ], "next": "None", "previous": "None", "total pages": 1 }
-
POST http://127.0.0.1:5000/api/v1/bucketlists/id/items create a new item in a bucket list
header
Authorization : Generated Token
body
{ "name":"buy a plot" }
response
{ "message": "buy a plot item created successfully" }