This repo demonstrates simple Todo App in Flask with following components:
- Flask SqlAlchemy
- Flask Migrate
- Flask Restful
- Flask Jwt Extended
git clone https://github.com/aydin/flask-todo-app
cd flask-todo-app
pip install -r requirements.txt
export FLASK_APP=todo.py
Run the following commands to create your app's database tables and perform the initial migration
flask db init
flask db migrate
flask db upgrade
To run the web application:
flask run
tox
docker-compose up
- Register
curl -X POST \
http://127.0.0.1:5000/registration \
-H 'Accept: application/json' \
-H 'Content-Type: application/json; charset=utf-8' \
-d '{"username":"john","password":"johndoe"}'
Get acess_token from response and use it for next requests in Authorization header.
- Create Todo item
curl -X POST \
http://127.0.0.1:5000/todos \
-H 'Accept: application/json' \
-H 'Authorization: Bearer your_access_token' \
-H 'Content-Type: application/json; charset=utf-8' \
-d '{"name":"todo item 1", "due_date": "2019-02-20"}'
- List Todo items
curl -X GET \
http://127.0.0.1:5000/todos \
-H 'Accept: application/json' \
-H 'Authorization: Bearer your_access_token' \
-H 'Content-Type: application/json; charset=utf-8'
- Update Todo item
curl -X PUT \
http://127.0.0.1:5000/todos/1 \
-H 'Accept: application/json' \
-H 'Authorization: Bearer your_access_token' \
-H 'Content-Type: application/json; charset=utf-8' \
-d '{"name": "updated todo item"}'
- Delete Todo item
curl -X DELETE \
http://127.0.0.1:5000/todos/2 \
-H 'Accept: application/json' \
-H 'Authorization: Bearer your_access_token' \
-H 'Content-Type: application/json; charset=utf-8'
- Revoke access token
curl -X POST \
http://127.0.0.1:5000/logout/access \
-H 'Accept: application/json' \
-H 'Authorization: Bearer your_access_token' \
-H 'Content-Type: application/json; charset=utf-8'
- Revoke refresh token
curl -X POST \
http://127.0.0.1:5000/logout/refresh \
-H 'Accept: application/json' \
-H 'Authorization: Bearer your_refresh_token' \
-H 'Content-Type: application/json; charset=utf-8'