<s> from flask import Flask , render_template , session , redirect , url_for , flash <EOL> from flask . ext . script import Manager <EOL> from flask . ext . bootstrap import Bootstrap <EOL> from flask . ext . moment import Moment <EOL> from flask . ext . wtf import Form <EOL> from wtforms import StringField , SubmitField <EOL> from wtforms . validators import Required <EOL> app = Flask ( __name__ ) <EOL> app . config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> manager = Manager ( app ) <EOL> bootstrap = Bootstrap ( app ) <EOL> moment = Moment ( app ) <EOL> class NameForm ( Form ) : <EOL> name = StringField ( '<STR_LIT>' , validators = [ Required ( ) ] ) <EOL> submit = SubmitField ( '<STR_LIT>' ) <EOL> @ app . errorhandler ( <NUM_LIT> ) <EOL> def page_not_found ( e ) : <EOL> return render_template ( '<STR_LIT>' ) , <NUM_LIT> <EOL> @ app . errorhandler ( <NUM_LIT> ) <EOL> def internal_server_error ( e ) : <EOL> return render_template ( '<STR_LIT>' ) , <NUM_LIT> <EOL> @ app . route ( '<STR_LIT:/>' , methods = [ '<STR_LIT:GET>' , '<STR_LIT:POST>' ] ) <EOL> def index ( ) : <EOL> form = NameForm ( ) <EOL> if form . validate_on_submit ( ) : <EOL> old_name = session . get ( '<STR_LIT:name>' ) <EOL> if old_name is not None and old_name != form . name . data : <EOL> flash ( '<STR_LIT>' ) <EOL> session [ '<STR_LIT:name>' ] = form . name . data <EOL> return redirect ( url_for ( '<STR_LIT:index>' ) ) <EOL> return render_template ( '<STR_LIT>' , form = form , name = session . get ( '<STR_LIT:name>' ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> manager . run ( ) </s>
