blob: c642d17f3bbe2c088a705d78659d2773dbd9df89 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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()
|