Coder Social home page Coder Social logo

anthex / lora Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 291 KB

Php + js webapp displaying incoming data passed by HTTP POST requests in real time

Home Page: http://to52.dantz.fr

License: MIT License

PHP 6.79% CSS 5.64% Hack 1.03% JavaScript 85.25% Python 1.29%

lora's Introduction

TO52 - LoRa Backend

This web application processes incoming HTTP:POST requests, performs a basic check on the data, stores it in a csv file and displays it in the form of a google chart.

This project is being developped in the context of the TO52 course at UTBM

Screenshot

alt text

Features

  • User authentication using apache BasicAuth
  • User-configurable chart type and colors
  • Automatic cookies management for color choice
  • Chart update on csv file modification (no page/div reload)
  • Gluten-free

Todo

  • MySQL integration
  • Data structure rewrite for more flexibility
  • User-friendly functions
  • Automatic installation script with field configuration

Deployment instructions

  • Clone this repo
  • Create and edit .htaccess and .htpasswd for BasicAuth usage
  • Edit the data structures according to your needs
  • Send your POST requests to http://yoursever/restricted/submit.php (See python script in LoRa-Python)

Python request example (2.7)

Basic script to send POST request with 2 numeric arguments File : python_example/rest.py

usage example:

python ./rest.py 42 69

Code:

import urllib2
import urllib
import sys

username='yourusername'
password='yourpassword'

url = 'http://yourserver/restricted/submit.php/'
req = urllib2.Request(url)

values = {'temperature' : sys.argv[1] ,'humidite' : sys.argv[2]}
data = urllib.urlencode(values)
req.add_data(data)

#authentication
password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
password_manager.add_password(None, url, username, password)
auth_manager = urllib2.HTTPBasicAuthHandler(password_manager)
opener = urllib2.build_opener(auth_manager)
urllib2.install_opener(opener)

#send request
code = type = 0

try:
   handler = urllib2.urlopen(req)
   code = handler.getcode()
   type = handler.headers.getheader('content-type')
except:
   print("error")
   code = -1


if code == 200:
   print("Requete envoyee avec succes.")
elif code == 401:
   print("Erreur d'authentification")
else:
   print("Erreur d'envoi de la requete. Code " + str(code))

lora's People

Contributors

anthex avatar

Watchers

James Cloos avatar  avatar

Forkers

marui22

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.