A simple api using flask (python) and sqlite
- flask (https://github.com/pallets/flask)
- sqlite (https://sqlite.org/index.html)
- sqlite3 (https://docs.python.org/3/library/sqlite3.html)
- Postman (optional for testing api)
- SQLiteStudio (optional for managing database) (https://sqlite.org/index.html)
-
config (config.json, config.py)
- configuration file
-
server (api.py)
- creates server and listens on a port 3000
-
controller (controller.py)
- defines routing and request handlers
-
service (service.py)
- handles business logic
-
model
- data
-
dbContext (dbContext.py)
- handles db connection
-
database (sqlite)
- sqlite database
Run the following command from the root directory:
python api.py
Try the following urls in Postman.
-
GetTasks (GET)
-
GetTask (GET)
-
AddTask (POST)
- http://127.0.0.1:3000/addtask
- body -> raw, json
- { "id" : "1", "name": "task1", "description": "task1", "priority": "low", "status": "none" }
-
UpdateTask (POST)
- http://127.0.0.1:3000/updatetask
- body -> raw, json
- { "id" : "1", "name": "task11", "description": "task11", "priority": "medium", "status": "started" }
-
DeleteTask (POST)
- http://127.0.0.1:3000/deletetask
- body -> raw, json
- { "id" : "1" }