Demo entry 6317001



Submitted by anonymous on Nov 04, 2016 at 23:26
Language: Python 3. Code size: 1.4 kB.

from flask import Flask, render_template, jsonify, request, url_for
import serial
import datetime
import os

app = Flask(__name__)

ser = serial.Serial('/dev/ttyUSB0')

def  index():
	return  render_template('index.html', menu='home.html')

def arduino():
	y_temp = float(ser.readline().decode("utf-8").strip("\n"))
	i =
	data = "{0}/{1}/{2} {3}:{4}:{5} Temperature is : {6}".format(, i.month, i.year, i.hour, i.minute, i.second, round(y_temp,2))
	return  render_template('index.html', menu='arduino.html', data=data)
#javascript functions
def updatedata():
	y_temp = float(ser.readline().decode("utf-8").strip("\n"))
	data = round(y_temp,5)
	return jsonify(result=data)
#for css update	
def override_url_for():
    return dict(url_for=dated_url_for)

def dated_url_for(endpoint, **values):
    if endpoint == 'static':
        filename = values.get('filename', None)
        if filename:
            file_path = os.path.join(app.root_path,
                                     endpoint, filename)
            values['q'] = int(os.stat(file_path).st_mtime)
    return url_for(endpoint, **values)	
if __name__  == "__main__":'',
			debug = True)

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).