Files
flask-beertap/beertap/views.py
2022-07-17 14:01:38 +02:00

37 lines
987 B
Python

import json
from flask import Blueprint, render_template, request, flash, jsonify
from gpio_handler import create_output
views = Blueprint('views', __name__)
# tap channels
tap_left=26
tap_right=20
# create ouput handler
output = create_output()
output.gpio_test()
@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!")
output.gpio_set_pulse(channel=tap_left, time_on=6)
if request.form['submit_button'] == 'option_2':
print("Eis usem rächte Gütterli uselah!")
output.gpio_set_pulse(channel=tap_right, time_on=6)
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')