Skip to content

Nutria-LUG/openair-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenAir_Server

Django server and APIs for Openair surveys and errors registration.

Prerequisites

Required packages:

  • python3
  • python3-pip

Optional packages:

  • git (to clone the repository)
  • python3-venv (to install into a virtual env)

Setting up the virtual environment (optional)

In order to install the server into a virtual environment, to delete everything later, we use the following code:

# create the folder
python3 -m venv .venv
# activate the virtual environment
source .venv/bin/activate

Get Started

First of all, we need to clone the repository, install dependencies, create the db (sqlite3) and then run the server. Optionally, we can add a super-user to access the Django admin site.

# clone the repository
git clone https://github.com/Nutria-LUG/OpenAir_Server openair-server
cd openair-server
# install dependencies
pip3 install -r requirements.txt
# create the db
python3 manage.py migrate
# add a super-user (optional)
python3 manage.py createsuperuser
# models registration
python3 manage.py makemigrations
python3 manage.py migrate
# run the server
python3 manage.py runserver

Models

Following, models used for storing data from surveys and errors.

Device

  • name (string): name
  • mac_address (string): MAC address
  • ip_address (string): static IP assigned to the device
  • enum (integer): enum to identify the device
  • active (boolean): if disabled, API will reject requests

Sensor

  • name (string): name
  • code (string): hexadecimal sensor code
  • enum (integer): enum to identify the sensor
  • active (boolean): unused

Survey

  • inserted (datetime): set by the server, it's the timestamp of the inserted row
  • timestamp (integer): timestamp of the survey (client detection)
  • device (Device): set by the server, it's filled using the client ip, obtained by the request
  • sensor (Sensor): set by the server, it's filled using the enum sent with the request
  • value (float): value of the survey

Error

  • inserted (datetime): set by the server, it's the timestamp of the inserted row
  • timestamp (integer): timestamp of the error (client detection)
  • device (Device): set by the server, it's filled using the client ip, obtained by the request
  • message (string): error message

APIs

Current project makes use of Django REST framework library.

Surveys

The API method will refuse all requests sent by clients with IPs not defined into the Device table.

  • address: /openair/api/survey
  • method: POST
  • accept: JSON
  • responses: 201 (created), 400 (bad request)
  • data: object, array of objects
    • timestamp (timestamp)
    • sensor (integer)
    • value (float)

Errors

The API method will refuse all requests sent by clients with IPs not defined into the Device table.

  • address: /openair/api/error
  • method: POST
  • accept: JSON
  • responses: 201 (created), 400 (bad request)
  • data: object, array of objects
    • timestamp (timestamp)
    • message (string)

About

Django server for surveys registration

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages