59 lines
1.8 KiB
Python
59 lines
1.8 KiB
Python
from flask import Flask, render_template, request, redirect, url_for
|
|
from flask_navigation import Navigation
|
|
from FileIO import loadZones
|
|
from Translater import Translater, Language
|
|
from Zone import getZone
|
|
|
|
|
|
|
|
def startWebserver(port, translater, zones):
|
|
|
|
|
|
app = Flask("Bewässerungssystem")
|
|
nav = Navigation(app)
|
|
|
|
nav.Bar('top', [
|
|
nav.Item(translater.getTranslation('Dashboard'), 'showDashboard'),
|
|
nav.Item(translater.getTranslation('irrigation zones'), 'showZones'),
|
|
nav.Item(translater.getTranslation('blocking times'), 'showTimes'),
|
|
nav.Item(translater.getTranslation('system settings'), 'showSystem')
|
|
#nav.Item('Gfg', 'gfg', {'page': 5}), #(example with pages)
|
|
])
|
|
|
|
#Example Route with pages:
|
|
#@app.route('/gfg/<int:page>')
|
|
#def gfg(page):
|
|
# return render_template('gfg.html', page=page)
|
|
|
|
|
|
@app.route('/')
|
|
def startPage():
|
|
return redirect(url_for('showDashboard'))
|
|
|
|
@app.route('/dashboard')
|
|
def showDashboard():
|
|
return render_template('dashboard.html', translater=translater, zones=zones)
|
|
|
|
@app.route('/zones')
|
|
@app.route('/zones/<zoneNumber>')
|
|
def showZones(zoneNumber=False):
|
|
if(zoneNumber):
|
|
return render_template('zone.html', translater=translater, zone=getZone(zones, zoneNumber))
|
|
else:
|
|
return render_template('zones.html', translater=translater, zones=zones)
|
|
|
|
|
|
@app.route('/times')
|
|
def showTimes():
|
|
return render_template('times.html', translater=translater)
|
|
|
|
@app.route('/system')
|
|
def showSystem():
|
|
return render_template('system.html', translater=translater)
|
|
|
|
app.run(debug=True, port=port)
|
|
|
|
if __name__ == "__main__":
|
|
zones = loadZones()
|
|
translater = Translater(Language.ENGLISH)
|
|
startWebserver(80, translater, zones) |