def greetings(key_id=None): if request.method == 'GET': if key_id: entity = ds.get_by_id(key_id) if not entity: abort(404) return entity greetings = ds.get_all() res = {'greetings': greetings} return res elif request.method == 'POST': author = request.json['author'] message = request.json['message'] entity = ds.insert(author, message) return entity, 201 elif request.method == 'PUT': entity = ds.get_by_id(key_id) if not entity: abort(404) return entity entity['author'] = request.json['author'] entity['message'] = request.json['message'] entity = ds.update(entity) return entity elif request.method == 'DELETE': ds.delete(key_id) return '', 204
def admin(): # ログインしていなければトップへリダイレクト if not is_login(): return show_msg("認証失敗。ログインが必要なページです。") data = ds.get_all() message = "ToDoList 管理画面" return render_template('works/todo_admin.html', message=message, data=data)
def greetings(key_id=None): if request.method == 'GET': if key_id: entity = ds.get_by_id(key_id) if not entity: abort(404) return entity greetings = ds.get_all() res = {'greetings': greetings} return res elif request.method == 'POST': author = request.json['author'] message = request.json['message'] entity = ds.insert(author, message) return entity, 201
def todo(): data = ds.get_all() message = "ToDoList にようこそ!" return render_template('works/todo.html', message=message, data=data)