|
|
|
@ -1,25 +1,16 @@ |
|
|
|
|
from app import app |
|
|
|
|
from app import db |
|
|
|
|
from app.forms import LoginForm, RegistrationForm, CheckForm |
|
|
|
|
from app.forms import LoginForm, RegistrationForm |
|
|
|
|
from app.models import User |
|
|
|
|
from flask import render_template, flash, redirect, url_for, request |
|
|
|
|
from flask import render_template, flash, redirect, url_for |
|
|
|
|
from flask_login import current_user, login_user, logout_user |
|
|
|
|
from flask_login import login_required |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/') |
|
|
|
|
@app.route('/index', methods=['GET', 'POST']) |
|
|
|
|
@app.route('/index') |
|
|
|
|
def index(): |
|
|
|
|
form = CheckForm() |
|
|
|
|
if request.method == 'POST': |
|
|
|
|
text = request.form['text'] |
|
|
|
|
return render_template('result.html', title='Result', text=text) |
|
|
|
|
else: |
|
|
|
|
if form.validate_on_submit(): |
|
|
|
|
flash('Check requested for text {}'.format( |
|
|
|
|
form.text.data)) |
|
|
|
|
return redirect(url_for('index')) |
|
|
|
|
return render_template('index.html', title='Check', form=form) |
|
|
|
|
return "Hello, World!" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/register', methods=['GET', 'POST']) |
|
|
|
@ -40,7 +31,7 @@ def register(): |
|
|
|
|
@app.route('/login', methods=['GET', 'POST']) |
|
|
|
|
def login(): |
|
|
|
|
if current_user.is_authenticated: |
|
|
|
|
return redirect(url_for('admin')) |
|
|
|
|
return redirect(url_for('index')) |
|
|
|
|
form = LoginForm() |
|
|
|
|
if form.validate_on_submit(): |
|
|
|
|
user = User.query.filter_by(username=form.username.data).first() |
|
|
|
@ -55,7 +46,7 @@ def login(): |
|
|
|
|
@app.route('/admin') |
|
|
|
|
@login_required |
|
|
|
|
def admin(): |
|
|
|
|
return render_template('admin.html') |
|
|
|
|
return "Hello, World!" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/logout') |
|
|
|
|