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