https://github.com/kevinkoech357/stage_two_backend
REST API
https://github.com/kevinkoech357/stage_two_backend
flask flask-sqlalchemy sqlite-database
Last synced: 3 months ago
JSON representation
REST API
- Host: GitHub
- URL: https://github.com/kevinkoech357/stage_two_backend
- Owner: kevinkoech357
- Created: 2023-09-11T13:49:21.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-15T05:35:44.000Z (over 1 year ago)
- Last Synced: 2025-01-05T05:41:41.770Z (4 months ago)
- Topics: flask, flask-sqlalchemy, sqlite-database
- Language: Python
- Homepage: https://stagetwo-api-hngx.onrender.com/api
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# API DOCUMENTATION
## Introduction
This repository hosts a REST API built using flask framework and sqlite as the database. It allows the user to perform different CRUD operations on a person resource, specifically name. Navigate to different directories to see the code:```bash
(env) kevinkoech357@kevinkoech:~/Personal/HNGx/stage_two_backend$ tree -L 2
.
├── app
│ ├── database
│ ├── __init__.py
│ ├── models
│ ├── __pycache__
│ └── routes
├── docs
│ └── DOCUMENTATION.md
├── instance
│ └── test.db
├── __pycache__
│ └── run.cpython-311.pyc
├── README.md
├── requirements.txt
└── run.py
```## Usage
### Cloning repository
```bash
git clone https://github.com/kevinkoech357/stage_two_backend
cd stage_two_backend
```
### Creating virutalenv
```bash
python3 -m venv env
source env/bin/activate
```
### Installing dependencies
```bash
pip install -r requirements.txt
```
### Starting server
```bash
gunicorn -w 4 run:app
```## Testing
### Using curl
#### Create a new person:
```bash
curl -X POST -H "Content-Type: application/json" -d '{"name": "John Doe"}' http://localhost:8000/api
```
#### Retrieve details of a person by ID:
```bash
curl http://localhost:8000/api/1
```
#### Retrieve all persons
```bash
curl -X GET http://localhost:8000/api/all
```
#### Update the details of an existing person:
```bash
curl -X PUT -H "Content-Type: application/json" -d '{"name": "Updated Name"}' http://localhost:8000/api/1
```
#### Remove a person by ID:
```bash
curl -X DELETE http://localhost:8000/api/1
```
### Using Postman
Visit ```https://www.postman.com/kevinkoech357/workspace/hng-stage-two-internship/collection/29637783-a59d3879-5053-4704-958e-d97db1f62021?action=share&creator=29637783``` to check collection and add more tests.### UML Diagram
Navigate to docs and open uml_diagram or click ```https://github.com/kevinkoech357/stage_two_backend/blob/main/docs/uml_diagram```