This is a simple Flask-based API for managing tasks. It provides endpoints for creating, updating, and deleting tasks, as well as retrieving tasks by status or priority.
- Python 3.x
- Flask
- sqlite3
- Clone this repository:
git clone https://github.com/your-username/task-manager-api.git ```
- Create a virtual environment:
python3 -m venv env ```
- Activate the virtual environment:
source env/bin/activate ```
- Install the required packages:
pip install -r requirements.txt ```
- Run the Flask app:
flask run ``` The app will be available at http://localhost:5000.
The following endpoints are available:
GET /tasks
- Get all tasksGET /tasks/<int:task_id>
- Get a specific task by IDPOST /tasks
- Create a new taskPUT /tasks/<int:task_id>
- Update an existing taskDELETE /tasks/<int:task_id>
- Delete a taskGET /tasks?status=<status>
- Get tasks by statusGET /tasks?priority=<priority>
- Get tasks by priority
The API accepts and returns JSON data. Here are the formats for the request and response bodies:
Request:
{
"title": "Task title",
"description": "Task description",
"status": "Not started",
"priority": "Low",
"due_date": "2023-05-10"
}
Response:
{
"task": {
"id": 1,
"title": "Task title",
"description": "Task description",
"status": "Not started",
"priority": "Low",
"due_date": "2023-05-10"
}
}
Request:
{
"title": "Updated task title",
"description": "Updated task description",
"status": "In progress",
"priority": "High",
"due_date": "2023-05-15"
}
Response:
{
"id": 1,
"title": "Updated task title",
"description": "Updated task description",
"status": "In progress",
"priority": "High",
"due_date": "2023-05-15"
}
Response:
{
"tasks": [
{
"id": 1,
"title": "Task title",
"description": "Task description",
"status": "Not started",
"priority": "Low",
"due_date": "2023-05-10"
},
{
"id": 2,
"title": "Another task",
"description": "Another task description",
"status": "In progress",
"priority": "Medium",
"due_date": "2023-05-12"
}
]
}
The API returns the following HTTP error codes:
- 400 Bad Request - if the request is malformed or missing required parameters
- 404 Not Found - if the requested task does not exist
- 500 Internal Server Error - for any other error
This project is licensed under the MIT License - see the LICENSE file for details.