|
@ -1,4 +1,4 @@ |
|
|
from flask import Flask, render_template, session, redirect, url_for |
|
|
|
|
|
|
|
|
from flask import Flask, render_template, session, redirect, url_for, flash |
|
|
from flask_bootstrap import Bootstrap |
|
|
from flask_bootstrap import Bootstrap |
|
|
from flask_moment import Moment |
|
|
from flask_moment import Moment |
|
|
from flask_wtf import FlaskForm |
|
|
from flask_wtf import FlaskForm |
|
@ -32,6 +32,9 @@ def internal_server_error(e): |
|
|
def index(): |
|
|
def index(): |
|
|
form = NameForm() |
|
|
form = NameForm() |
|
|
if form.validate_on_submit(): |
|
|
if form.validate_on_submit(): |
|
|
|
|
|
old_name = session.get('name') |
|
|
|
|
|
if old_name is not None and old_name != form.name.data: |
|
|
|
|
|
flash('Loks like you have changed your name!') |
|
|
session['name'] = form.name.data |
|
|
session['name'] = form.name.data |
|
|
return redirect(url_for('index')) |
|
|
return redirect(url_for('index')) |
|
|
return render_template('index.html', form=form, name=session.get('name')) |
|
|
return render_template('index.html', form=form, name=session.get('name')) |