From cf70ae6ded332729f0dc2833d6680d7dac8072db Mon Sep 17 00:00:00 2001 From: root Date: Fri, 7 Jan 2022 19:19:45 +0000 Subject: Commiting basic code --- main.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 main.py (limited to 'main.py') diff --git a/main.py b/main.py new file mode 100644 index 0000000..c642d17 --- /dev/null +++ b/main.py @@ -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/') +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() -- cgit v1.2.3