<s> from app import app <EOL> from flask import render_template , request , jsonify <EOL> from app . models import Todo <EOL> from datetime import datetime <EOL> @ app . route ( '<STR_LIT:/>' ) <EOL> def index ( ) : <EOL> return render_template ( "<STR_LIT>" ) <EOL> @ app . route ( '<STR_LIT>' , methods = [ '<STR_LIT:POST>' , ] ) <EOL> def add ( ) : <EOL> form = request . form <EOL> content = form . get ( '<STR_LIT:content>' ) <EOL> todo = Todo ( content = content , time = datetime . now ( ) ) <EOL> todo . save ( ) <EOL> return jsonify ( status = "<STR_LIT:success>" ) <EOL> @ app . route ( '<STR_LIT>' ) <EOL> def delete ( todo_id ) : <EOL> todo = Todo . objects . get_or_404 ( id = todo_id ) <EOL> todo . delete ( ) <EOL> return jsonify ( status = "<STR_LIT:success>" ) <EOL> @ app . route ( '<STR_LIT>' , methods = [ '<STR_LIT:POST>' , ] ) <EOL> def update ( ) : <EOL> form = request . form <EOL> todo_id = form . get ( '<STR_LIT:id>' ) <EOL> status = form . get ( '<STR_LIT:status>' ) <EOL> todo = Todo . objects . get_or_404 ( id = todo_id ) <EOL> todo . status = status <EOL> todo . save ( ) <EOL> return jsonify ( status = "<STR_LIT:success>" ) <EOL> @ app . route ( '<STR_LIT>' ) <EOL> def list ( ) : <EOL> todos = Todo . objects . order_by ( '<STR_LIT>' ) <EOL> return jsonify ( status = "<STR_LIT:success>" , todos = [ todo . to_json ( ) for todo in todos ] ) </s>
