Git Product home page Git Product logo

quotes-rest-api's Introduction

Quotes-Rest-API

Implemented a REST API that manages quotes.

Tech Stack

Part 1: Implementation

A quote has the following fields:

  • author (string): The name of the author of the quote (optional).
    • e.g. 'Oscar Wilde'
  • text (string): The text of the quote (mandatory).
    • e.g. 'The truth is rarely pure and never simple.'

The API supports the following operations.

  • Create a quote:
    • /quotes, method=POST
    • Fields of quote should be provided in body of request in a json format.
  • Update a quote with a specific ID:
    • /quotes/<id>, method=PUT
    • Fields of quote should be provided in body of request in a json format.
  • Get a quote with a specific ID:
    • /quotes/<id>, method=GET
  • Delete a quote with a specific ID:
    • /quotes/<id>, method=DELETE
  • Get a random quote:
    • /quotes/random, method=GET
  • Get all quotes:
    • /quotes, method=GET
  • Get quotes that contain specific text (e.g. "discover"):
    • /quotes/substring, method=GET
    • Substring of quote should be provided as a value in body of request in a json format. Name of key can be anything you want.

(id in endpoint is the object id generated automatically in the field '_id')

Part 2: Testing

Tested with pytest endpoints that create, update and return a quote.

Part 3: Containerization

Wrote Dockerfile for the application.

Wrote a Compose file to define and run the application as a set of containers (one container for the application, one container for the database).

Used Docker and Docker Compose.

Part 4: Running

# create and start (the first run takes time to build the image)
docker-compose up

# stop/restart
docker-compose stop
docker-compose start

# stop and remove
docker-compose down -v

# run tests
docker-compose run app python app_test.py

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.