Building a RESTful API for Task Management
Estimated completion time: 75 minutes
Exercise Overview You will apply the knowledge gained from the lecture on API endpoints, RESTful APIs, HTTP methods, and API authentication to implement a basic RESTful API for managing tasks The objective is to reinforce your understanding of these concepts by hands-on experience in creating a functional API using Python and a web framework (Flask) Objectives
Implement a RESTful API that allows for the management of tasks through CRUD operations (Create, Read, Update, Delete) This exercise will provide you with practical experience in designing API endpoints, handling various HTTP methods, and ensuring basic security through authentication
Instructions
Project Setup: Create a new Python project Set up the Flask web framework in your project Define Task Model: Define a model or class representing a task with attributes like id, title, description, and completed API Endpoints: Design API endpoints for the following CRUD operations: Create a new task * Retrieve all tasks * Retrieve a specific task by ID * Update an existing task * Delete a task * Implement Endpoint Logic: Implement the logic for each API endpoint to perform the corresponding CRUD operation * Ensure proper handling of HTTP methods (GET, POST, PUT, DELETE) for each endpoint * Error Handling and Response Formatting: Include basic error handling in your API * Format API responses in a clear and consistent manner API Authentication: Implement a basic authentication mechanism for your API You can choose between API keys or another simple authentication method Testing: Test your API using a tool like Postman or CURL to verify that each endpoint functions as expected Include test cases for both successful operations and error scenarios Submission: Submit a link of your github repo when complete