Git Product home page Git Product logo

rentacar_test's Introduction

RENTACAR

"rentacar_logo"

Super car management api

prerequisites

  • python3.10+
  • Postman ( this document supposes you use Postman)
  • install dependencies with $ pipenv install
  • or $ pip install -r requirements.txt if you want to stick with just pip
  • Optional: You may need the Postman Agent to overcome CORS restrictions
    • Must be lauched before using Postman

The agent can be downloaded at https://www.postman.com/downloads/postman-agent/

Launch server

  1. as vanilla Flask : python src/rentacar.py [--host/-H '127.0.0.1' --port/-P 8888 --debug/-D]

  2. As WSGI prod server using Gunicorn : gunicorn [--bind 127.0.0.1:8888] rentacar:app

see Gunicorn man page for more options

Usage

Without Token necessary

List available routes

"help"

Get token

"login"

Set token in Postman

"token"

Create car into database

"login"

Retrieve cars

all cars

"login"

retrieve with id

"login"

retrieve with query

"login"

Update cars

update with id

"login"

update with query

"login"

Delete cars

delete with id

"login"

delete with query

"login"

delete all database (WARNING)

"login"

WARNING

Before the dataabase purge, you may want to make a copy of it.

Add column (field) to the model

The library used to store data enforces the model after the first insertion.

In order to add a field , just edit the database file

{
    "version": 2,
    "keys": [
        "brand",
        "color",
        "year",
        "category" < # a new field can be added here
    ],
    "data": {
        "543984382318218286": {
            "brand": "Lada",
            "year": "1982",
            "color": "Soviet blue",
            "category": ""
        },
        "176342342618812623": {
            "year": "1978",
            "color": "Metal green",
            "brand": "Moskvitch",
            "category": "Public cars"
        },
        "224950951376616862": {
            "year": "1975",
            "brand": "ZIL-115",
            "color": "Black",
            "category": "Armored vehicle"
        }
    }
}

Once added , it can be used into the queries.

What is missing

  1. The library does not allow the easy update all records at once.
  2. A simple migration mechanism to update the database with new fields.
  3. A configuration file.

rentacar_test's People

Watchers

antares667367 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.