Git Product home page Git Product logo

flask-task's Introduction

Flask Task

A Flask blueprint developed to the Test Task

Summary

Installation

Clone the project

  git clone https://github.com/fabiobarkoski/flask-task.git

Go to the project directory

  cd flask-task

Current to install the dependencies you need the package manager Poetry. After installed type.

  poetry install

To start the App

  gunicorn --chdir ./src/ app:app

Running Tests

To run the tests, run the following command

  pytest

Docker

To build a image, run the following command inside the project folder

  docker build -t flask-task .

And after run

  docker run -p 8000:8000 flask-task

Documentation

To calculate the distance between the Moscow Ring Road and an adress I used the Haversine Formula. So to check the distance the application just need a coordinate or a name of a place/adress.

The Blueprint

The blueprint calculate by checking the GET Request.

  • If the request is a coordinate, then the blueprint will check if the adress is inside the Moscow Ring Road, if not the blueprint will calculate the distance and after add the result to the distance.log file
  • If is an adress. The blueprint will get the coordinate through a Geocoder API and then will do the same steps, check if it is inside the Moscow Ring Road, if not will calculate and add the result to the distance.log file

HTTP Request

  GET /${adress}
Parameter Type Description Response
adress string Required. The adress to calculate the distance If not inside the MKAD, save the response on the distance.log file

Examples

In the exemples I will use the coordinates of 2 places, 1 is the coordinate of Maryina Roshcha that is inside the MKAD and the another is the London coordinate

  GET /55.79691668126746, 37.599703014240795 //Maryina Roshcha coordinate

For being inside the MKAD, the blueprint will not calculate and add to distance.log file

  GET /51.50173484532344, -0.1254902875175711 //London coordinate

For being outside the MKAD, the blueprint will calculate and add to distance.log file. The .log file will seem like this:

  2021-08-25 17:49:58,199:INFO:blueprint_view.py:The distance from Moscow Ring Road to 51.50173484532344, -0.1254902875175711 is 2515 km

.ENV file

Inside the .env file you will se an empty API_TOKEN variable. Please put your Yandex Geocoder API Token inside this variable.

Author

flask-task's People

Stargazers

 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.