Skip to content

rajasalot/TestTask2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Person API - Django

This django_rest API allows you to manage a collection of persons with basic CRUD (Create, Read, Update, Delete) operations. You can use this API to perform actions on person records such as adding new persons, querying persons by name, updating their information, and deleting them.

Table of Contents

Getting Started

Prerequisites

Before setting up and running the Person API, ensure you have the following prerequisites installed:

  • Django
  • Django rest_framework

Installation

  1. Fork and clone the repository to your local machine:

    git clone <repository-url>
    cd person-api-django django rest_framework
  2. Install the project dependencies:

    pip install django

Running the API

To start the API server, run the following command:

python manage.py runserver

The server will start on port 8000 by default

API Endpoints

Get All People

  • Endpoint: GET /api/people
  • Description: Retrieves a list of all people in the database.
  • Response: 200 OK

Get Person by ID

  • Endpoint: GET /api/:user_id
  • Description: Retrieves a specific person by their ID.
  • Response: 200 OK or 404 Not Found

Create a New Person

  • Endpoint: POST /api

  • Description: Creates a new person in the database.

  • Request Body:

    {
      "name": "Harry Potter"
    }
  • Response: 201 Created or 400 Bad Request (in case of validation errors)

Update a Person

  • Endpoint: PUT /api/:user_id

  • Description: Updates a person's information by their ID.

  • Request Body:

    {
      "name": "Updated Name"
    }
  • Response: 200 OK or 404 Not Found

Delete a Person

  • Endpoint: DELETE /api/:name
  • Description: Deletes a person by their ID.
  • Response: 200 OK or 404 Not Found

Source Code

UML

Class Diagram

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published