<s> from flask import Flask <EOL> app = Flask ( __name__ ) <EOL> from google . appengine . ext import db <EOL> from google . appengine . api import users <EOL> from flask import redirect , url_for , request , render_template , abort , flash , get_flashed_messages <EOL> class Task ( db . Model ) : <EOL> user = db . UserProperty ( ) <EOL> name = db . StringProperty ( required = True ) <EOL> done = db . BooleanProperty ( ) <EOL> @ app . route ( '<STR_LIT:/>' ) <EOL> def list ( ) : <EOL> user = users . get_current_user ( ) <EOL> tasks = Task . all ( ) . filter ( '<STR_LIT>' , user ) <EOL> return render_template ( '<STR_LIT>' , user = user , logout_url = users . create_logout_url ( "<STR_LIT:/>" ) , tasks = tasks , flashes = get_flashed_messages ( ) ) ; <EOL> @ app . route ( '<STR_LIT:/>' , methods = [ '<STR_LIT:POST>' ] ) <EOL> def task_post ( ) : <EOL> name = request . form [ '<STR_LIT:name>' ] <EOL> if not name : <EOL> flash ( "<STR_LIT>" ) <EOL> return redirect ( url_for ( '<STR_LIT:list>' ) ) <EOL> task = Task ( name = request . form [ '<STR_LIT:name>' ] ) <EOL> task . user = users . get_current_user ( ) <EOL> task . put ( ) <EOL> return redirect ( url_for ( '<STR_LIT:list>' ) ) <EOL> @ app . route ( '<STR_LIT>' ) <EOL> def task_delete ( id ) : <EOL> task = Task . get_by_id ( id ) <EOL> if task and task . user == users . get_current_user ( ) : <EOL> task . delete ( ) <EOL> else : <EOL> abort ( <NUM_LIT> ) <EOL> return redirect ( url_for ( '<STR_LIT:list>' ) ) <EOL> @ app . route ( '<STR_LIT>' ) <EOL> def task_done ( id ) : <EOL> task = Task . get_by_id ( id ) <EOL> if task and task . user == users . get_current_user ( ) : <EOL> if task . done : <EOL> task . done = False <EOL> else : <EOL> task . done = True <EOL> task . put ( ) <EOL> else : <EOL> abort ( <NUM_LIT> ) <EOL> return redirect ( url_for ( '<STR_LIT:list>' ) ) <EOL> app . secret_key = '<STR_LIT>' <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> app . run ( ) </s>
