38 lines
978 B
Python
38 lines
978 B
Python
import json
|
|
|
|
from flask import Blueprint, render_template, request, flash, jsonify
|
|
from gpio_handler import gpio_set_pulse
|
|
|
|
views = Blueprint('views', __name__)
|
|
|
|
# gpio channels
|
|
r_ch1 = 26
|
|
r_ch2 = 20
|
|
r_ch3 = 21
|
|
|
|
# wait times
|
|
t_large_beer = 6
|
|
t_small_beer = 2
|
|
|
|
@views.route('/', methods=['GET'])
|
|
def render():
|
|
return render_template('beertap.html')
|
|
|
|
@views.route('/', methods=['POST'])
|
|
def choice():
|
|
if request.form['submit_button'] == 'option_1':
|
|
print("Eis usem lingge Gütterli uselah!")
|
|
gpio_set_pulse(channel=r_ch1, time_on=t_large_beer)
|
|
if request.form['submit_button'] == 'option_2':
|
|
print("Eis usem rächte Gütterli uselah!")
|
|
gpio_set_pulse(channel=r_ch2, time_on=t_large_beer)
|
|
return render_template('beertap.html')
|
|
|
|
@views.route('/about', methods=['GET'])
|
|
def about():
|
|
return render_template('about.html')
|
|
|
|
@views.route('/statistics', methods=['GET'])
|
|
def statistics():
|
|
return render_template('statistics.html')
|