CaptainVee / stage1

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stage 2 Task

This is a RESTful API for performing CRUD operation of a person.

Table of Contents

Getting Started

These instructions will guide you through setting up and running Your API Name on your local machine.

Prerequisites

Before you begin, ensure you have met the following requirements:

Installation

  1. Clone the repository to your local machine:

    git clone https://github.com/CaptainVee/stage1
  2. Navigate to the project directory:

    cd stage1
  3. Create and activate a virtual environment (optional but recommended):

    virtualenv venv
    source venv/bin/activate
  4. Install the required Python packages:

    pip install -r requirements.txt
  5. Apply migrations to create the database:

    python manage.py migrate

Usage

Starting the API To run the API locally, use the following command:

python manage.py runserver

The API will be accessible at http://127.0.0.1:8000/

API Endpoints

Create a Person (POST) Create a new person by sending a POST request to the following endpoint:

POST /api/

Example request body:

{
  "name": "John Doe"
}

Note name must be unique

Retrieve a Person (GET) Retrieve information about a person by sending a GET request to the following endpoint:

GET /api/

Example request body:

{
  "name": "John Doe"
}
or 
{
  "id": 5
}

Update a Person (PUT) Update a person's information by sending a PUT request to the following endpoint:

PUT /api/

Example request body:

{
  "id": id,
  "name": "Updated Name"
}

Delete a Person (DELETE) Delete a person by sending a DELETE request to the following endpoint:

DELETE /api/
{
  "name": "John Doe"
}
or 
{
  "id": 5
}

UML Diagram

Below is a simplified UML class diagram representing the structure and relationships of the PersonView API class and the Person model. (url)[https://drawsql.app/teams/captain/diagrams/stage2]

About


Languages

Language:Python 100.0%