from flask import Flask, render_template, redirect, url_for
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, BooleanField
from wtforms.validators import DataRequired

app = Flask(__name__)
app.config['SECRET_KEY'] = 'mijngeheimesleutel'

class GateControlForm(FlaskForm):
    open_gate = SubmitField('Open Gate')
    close_gate = SubmitField('Close Gate')
    debug_mode = BooleanField('Enable Debug Mode')
    check_camera = SubmitField('Check Camera')  # New button to check camera status

class InputForm(FlaskForm):
    name = StringField('Name', validators=[DataRequired()])
    submit = SubmitField('Submit')

@app.route('/', methods=['GET', 'POST'])
def dashboard():
    gate_status = "Closed"
    debug_mode = False
    form = GateControlForm()
    if form.validate_on_submit():
        if form.open_gate.data:
            gate_status = "Open"
        elif form.close_gate.data:
            debug_mode = form.debug_mode.data
        return render_template('dashboard.html', form=form, gate_status=gate_status, debug_mode=debug_mode)
    return render_template('dashboard.html', form=form, gate_status=gate_status, debug_mode=debug_mode)

if __name__ == '__main__':
    app.run(debug=True)