Coder Social home page Coder Social logo

flask-real-time-map's Introduction

flask-real-time-map

Display a live visualization of vehicle position data.

Vehicle position data visualized on a map

Setup

It is recommended to use an environment that lets you install python versions and dependencies specific to your project, such as virtualenv, pyenv or others.

This project has been tested using Python 3.5 and 3.6.

Run server locally

Install directly from Github:

pip install git+git://github.com/hedderich/flask-real-time-map.git

Or clone the repository and execute:

pip install .

Before starting the server, be sure to set the environment variables for Flask and the map application itself. You need to provide a configuration file that contains a Mapbox API key, just like in the example settings.

export FLASK_APP=real_time_map
export LIVEMAP_SETTINGS=~/local_settings.cfg

To make the app locally accessible on port 5000, just type:

flask run

Inside a Docker container

Relying on the uwsgi-nginx-flask-docker Docker image, it is possible to serve the API so far. However it does not work with a steady websocket connection yet, therefore the map will not be able to update itself when served from a docker container.

docker build -t live-map .
docker run -p 80:80 live-map

Run tests

python setup.py test

API reference

When an error occurs, the server will respond with an error status code depending on the issue and additionally an response message in case it is a client side error (4xx).

Register vehicle

POST /vehicles

Request body: { "id": "vehicle-uuid" }

Response: 204 No Content

Update location

POST /vehicles/:uuid/locations

Request body: { "lat": 10.0, "lng": 20.0, "at": "2017-09-01T12:00:00Z" }

Response: 204 No Content

Deregister vehicle

DELETE /vehicles/:uuid

Response: 204 No Content

Data storage

In order to perform a subsequent analysis, the application will store information about every API request in a relational database with a connection defined in the settings.

All timestamps are saved in UTC.

Listed below are the available objects and their attributes.

vehicle

Every vehicle that was ever registered and its universally unique identifier.

  • vehicle_uuid

vehicle_registration

The event when a vehicle gets registered or deregistered. The latest event for each vehicle determines if this vehicle is allowed to send location data.

  • vehicle
  • time
  • action

vehicle_location

The event when a vehicle emits a valid location (its position is inside of the "city boundaries").

  • vehicle
  • time
  • lat
  • lng

flask-real-time-map's People

Contributors

hedderich avatar

Stargazers

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