import sqlite3 import heating import sql import time from flask import Flask, render_template app = Flask(__name__) boiler = heating.rpi_heating() # paramaterised location of database file # Use of final data type global DBFILE DBFILE = 'data.db' db = sql.db(dbfile) @app.route('/') @app.route('/index.html') def index(): # paramaterised location of template in 'templates' folder return render_template( "main.html", actual_temp = boiler.temp, target_temp = boiler.target ) @app.route('/up') def form(): boiler.up() return render_template("main.html") @app.route('/down') def activity(): boilder.down() return render_template("main.html") @app.route('/export/') def export(opt): if opt == 'txt': pass elif opt == 'pdf': pass else: return render_template('error.html', error="Invalid export type") if __name__ == '__main__': # if the database file does not exist, create it try: open(dbfile) except: sql.setup(dbfile) app.run()