Giter VIP home page Giter VIP logo

enelion-task's Introduction

enelion-task

This is a back end code using Flask, to endpoint management.

Getting started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

Install all required modules running pip with the provided file:

pip install -r requirements.txt

Installing

As a first step create you own database in PostgreSQL with command as follow:

$ CREATE DATABASE enelion;

In file app.py, change POSTGRES credentials in order to match them with your system:

POSTGRES = {
    'user': '{{ user }}',
    'pw': '{{ password }}',
    'db': 'enelion',
    'host': '{{ host }}',
    'port': '{{ port }}',
}

Before the first run of the application, please perform following commands:

  • to initialize the database and enable migrations:
$ flask db init
  • make first migration to create prepared table in database:
$ flask db migrate
$ flask db upgrade

In order to test the application, the server should run, therefore, the command should be typed:

$ python app.py

API endpoints

GET /records

Returns all data from database in json format. Here example of returned json:

{
  "records": [
    {
      "id": 1, 
      "lat": 54.352024, 
      "lng": 18.646639, 
      "time_created": "Wed, 05 Feb 2020 22:40:03 GMT", 
      "time_updated": "Wed, 05 Feb 2020 22:50:20 GMT",, 
      "unit_value": 0.55
    }
  ]
}

POST /records

Accepts data in json format and adds it to the database. Here example of input json:

{ "lat": 54.352024, "lng": 18.646639, "unit_value": 0.55 }

URL passes id to methods

GET /records/<record_id>

Returns data on particular object from database in json format.

PUT /records/<record_id>

Accepts data in json format and replaces it for particular record in the database.

DELETE /records/<record_id>

Based on id, deleted record from the table in the database.

enelion-task's People

Contributors

juju-and avatar

Watchers

James Cloos avatar  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.