diff options
Diffstat (limited to 'main.py')
| -rw-r--r-- | main.py | 56 |
1 files changed, 56 insertions, 0 deletions
@@ -0,0 +1,56 @@ +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/<opt>') +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() |
