mercredi 28 mars 2018

sensor data printing on webserver(python-flask)

I want to print sensor data on web server with using import flask in raspberry pi. I receive sensor data from arduino to raspberry pi via bluetooth and this is code.

#! /usr/bin/python
import bluetooth
bd_addr=Mac Address
port=1
sock=bluetooth.BluetoothSocket(bluetooth.RFCOMM)
sock.connect((bd_addr,port))
data=""

while 1:
  try:
    data +=sock.recv(1024)
    data_end=data.find('\n')
    if data_end!=-1:
      rec=data[:data_end]
      print data
      data=data[data_end+1:]
  except KeyboardInterrupt:
    break
sock.close()

And If I run this code in Genie I can print sensor data in terminal. And I want to print this sensor data in web page with using import flask. How can I print in web server?




Aucun commentaire:

Enregistrer un commentaire