Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask, render_template, request, url_for,redirect
- from flask_wtf import FlaskForm
- from wtforms import SubmitField
- from flask_bootstrap import Bootstrap
- import pdb
- app = Flask(__name__)
- app.secret_key = 'sdgsdhsd'
- bootstrap = Bootstrap(app)
- # FORM BUTTON CREATING FOR VALIDATION CLICK
- class estadoForm(FlaskForm):
- botaopy = SubmitField('Confirmar voto')
- def __init__(self, *args, **kwargs):
- kwargs['csrf_enabled'] = False
- super(estadoForm, self).__init__(*args, **kwargs)
- #
- @app.route("/",methods=['GET'])
- def index():
- return render_template('index.html')
- @app.route("/votar",methods=['GET','POST'])
- def registraVoto():
- form = estadoForm(request.form)
- if request.method == 'GET':
- print('TO NO GET')
- elif request.method == 'POST':
- clickedJeh=request.form.getlist('getJeh')
- clickedEdu=request.form.getlist('getEdu')
- print('ANTES DO VALIDATE SUBMIT',form.validate_on_submit())
- print('FORM BOTAO',form.botaopy.data)
- print('Click JEH',clickedJeh)
- if 'jeh' in clickedJeh:
- print('ENTREI NO JEH IN CLICKED')
- if form.validate_on_submit():
- print('ENTROU NO VALIDATE',form.validate_on_submit())
- print('SEU VOTO: ',clickedJeh)
- elif clickedEdu:
- if form.validate_on_submit():
- print('ENTROU NO VALIDATE',form.validate_on_submit())
- print('SEU VOTO: ',clickedEdu)
- else:
- return redirect('/')
- return render_template('teste-mach.html',form=form)
- app.run(host='localhost',port=7000, debug=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement