Skip to content

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

User Management CRUD API

This is a Python-based RESTful API for managing users, built using Flask and SQLAlchemy.

Features

  • Create, Read, Update, and Delete (CRUD) operations for users.
  • Modular structure with clear separation of concerns.
  • Proper error handling with HTTP status codes.
  • Unit tests to ensure functionality.

How to Run the Code

Follow these steps to set up and run the application:

1. Set Up the Virtual Environment

python -m venv venv
source venv/bin/activate   # On Windows: venv\Scripts\activate

2. Install Dependencies

Install the required Python packages:

pip install -r requirements.txt

3. Run the Application

Start the Flask server:

python app.py

The server will run at http://127.0.0.1:5000.

4. Run the Unit Tests

Execute the unit tests to verify functionality:

python -m unittest discover tests

Example API Endpoints

Create a User

  • POST /api/users
  • Request Body:
    {
      "name": "John Doe",
      "email": "john@example.com"
    }

Get All Users

  • GET /api/users

Get a User by ID

  • GET /api/users/<id>

Update a User

  • PUT /api/users/<id>
  • Request Body:
    {
      "name": "Jane Doe",
      "email": "jane@example.com"
    }

Delete a User

  • DELETE /api/users/<id>

Output Example

After running the application, here’s what the responses might look like:

  • GET /api/users:

    []
  • POST /api/users:

    {
      "id": 1,
      "name": "John Doe",
      "email": "john@example.com"
    }

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages