Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import render_template, flash, redirect
- from app import app
- from forms import LoginForm
- import random
- import time
- counter = 0
- @app.route('/index', methods = ['GET'])
- def index():
- answer = 0
- first = 0
- second = 0
- form = LoginForm()
- first = random.randint(1, 10)
- second = random.randint(1, 10)
- answer = first*second
- return render_template("index.html",
- first = first,
- second = second,
- form = form,
- answer = answer)
- @app.route('/index', methods = ['POST'])
- def check():
- numb = 0
- global counter
- if form.validate_on_submit():
- numb = int(form.answer.data)
- if numb == answer:
- counter += 1
- return redirect('/index')
- else:
- counter = 0
- return redirect('/index')
- return render_template("index.html",
- numb = numb,
- counter = counter)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement