Advertisement
Guest User

Py Face Match

a guest
Apr 3rd, 2020
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.48 KB | None | 0 0
  1. from flask import Flask, render_template, request, url_for,redirect
  2. from flask_wtf import FlaskForm
  3. from wtforms import SubmitField
  4. from flask_bootstrap import Bootstrap
  5. import pdb
  6.  
  7. app = Flask(__name__)
  8. app.secret_key = 'sdgsdhsd'
  9. bootstrap = Bootstrap(app)
  10.  
  11. # FORM BUTTON CREATING FOR VALIDATION CLICK
  12. class estadoForm(FlaskForm):
  13.     botaopy = SubmitField('Confirmar voto')
  14.  
  15.     def __init__(self, *args, **kwargs):
  16.         kwargs['csrf_enabled'] = False
  17.         super(estadoForm, self).__init__(*args, **kwargs)
  18. #
  19.  
  20.  
  21.  
  22. @app.route("/",methods=['GET'])
  23. def index():
  24.  
  25.     return render_template('index.html')
  26.  
  27. @app.route("/votar",methods=['GET','POST'])
  28. def registraVoto():
  29.     form = estadoForm(request.form)
  30.  
  31.     if request.method == 'GET':
  32.         print('TO NO GET')
  33.     elif request.method == 'POST':
  34.  
  35.         clickedJeh=request.form.getlist('getJeh')
  36.         clickedEdu=request.form.getlist('getEdu')
  37.         print('ANTES DO VALIDATE SUBMIT',form.validate_on_submit())
  38.         print('FORM BOTAO',form.botaopy.data)
  39.         print('Click JEH',clickedJeh)
  40.         if 'jeh' in clickedJeh:
  41.             print('ENTREI NO JEH IN CLICKED')
  42.             if form.validate_on_submit():
  43.                 print('ENTROU NO VALIDATE',form.validate_on_submit())
  44.                 print('SEU VOTO: ',clickedJeh)
  45.         elif clickedEdu:
  46.             if form.validate_on_submit():
  47.                 print('ENTROU NO VALIDATE',form.validate_on_submit())
  48.                 print('SEU VOTO: ',clickedEdu) 
  49.     else:
  50.         return redirect('/')
  51.  
  52.     return render_template('teste-mach.html',form=form)
  53.  
  54. app.run(host='localhost',port=7000, debug=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement