Giter Club home page Giter Club logo

person_api's Introduction

Create a REST API

The second task for HNG Internship is to develop a REST API with Basic CRUD Operation.

Tech Stack

Framework: FastAPI

Server: uvicorn

Databases: SQLite (local), PostgreSQL (production)

Run Locally

If you choose to fork before cloning the project be sure to use the link from your own repo to clone.

Clone the project

  git clone https://github.com/A3AJAGBE/person_api

Go to the project directory

  cd person_api

Create virtual environment

  python3 -m venv venv

Activate virtual environment

  source venv/bin/activate

Install dependencies

  pip install -r requirements.txt

Start the server

  uvicorn main:app --reload

Environment Variables

To run this project, you will need to create a .env file and add the environment variable to it.

DATABASE_URL

an example on how to set the variable

DATABASE_URL = "sqlite:///[INSERT DB NAME HERE].db"

API Reference

POST the data

POST /api
Parameter Type Description
name string Required

GET all the data

GET /

GET the data by id

GET /api/{user_id}
Parameter Type Description
id integer Required

GET the data by using name

GET /api?name=[INSERT HERE]
Parameter Type Description
name string Required

PUT the data by id

PUT /api/{user_id}
Parameter Type Description
id integer Required

DELETE the data by id

DELETE /api/{user_id}
Parameter Type Description
id integer Required

Running Tests

A test file "sql_test.py" has been created with tests to check. To run tests, run the following command

  pytest

Deployment

This API is deployed on Railway. Locally the database used is SQLite while for production it's PostgreSQL.

psycopg2-binary was installed due to the production database.

Limitations/Assumptions

  • Familiarity with Python
  • Familiarity with git and GitHub
  • No auth Implementation for the API
  • The application was developed on MacOS
  • Knowledge of using the command line interface (CLI)

Appendix

The "person.db" database should be deleted, if you named or wish to name your database some different from "person".

If you are using a different device, lookup on how certain things are done. e.g creating a virtual environment.

person_api's People

Contributors

a3ajagbe avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.