# Imports from flask import Flask from flask import render_template from flask import jsonify from flask import request from flask import redirect from models import Samples from aux_pro import Process from database import Database import time samples = Samples() app = Flask(__name__) db = Database() proc = Process() @app.route('/') def index(): proc.start_process() samples = db.get_last_ten() promedios = db.get_promedio() return render_template('index.html', samples=samples, promedios=promedios, refresco=5) @app.route('/stop') def stop():
# Import de librerias from flask import Flask from flask import render_template from aux_pro import Process from database import Database from flask import redirect from flask import jsonify from flask import request import datetime import os app = Flask(__name__) db = Database() pro = Process() if __name__ == "__main__": app.run(host='0.0.0.0', port=8888) # Ruta inicial @app.route('/', methods=["GET"]) # Metodo inicial def index(): if not pro.is_running(): pro.start_process() print("Empezando process ") return last_10_events() # Metodo que retornan los ultimos 10 eventos def last_10_events():
# Imports from flask import Flask from flask import render_template from aux_pro import Process from flask import redirect from database import Database from flask import jsonify app = Flask(__name__) p = Process() db = Database() #Punto de entrada de Flask @app.route('/') def index(): if not p.is_running(): p.start_process() else: print("Already working") return render_template('index.html') if __name__ == "__main__": app.run(host='0.0.0.0', port=9999) #Función para renderizar los promedios y las últimas 10 muestras @app.route('/avg/', methods=["GET"])