def add(): # ログインしていなければトップへリダイレクト if not is_login(): return show_msg("認証失敗。ログインが必要なページです。") addtodo = request.form.get('addtodo', '') if addtodo == '': return redirect('/works/todo/admin') things = addtodo check = "0" ds.insert(things, check) return redirect('/works/todo/admin')
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 greetings(key_id=None): if request.method == 'GET': if key_id: igarashi = { 'id': key_id, 'author': 'Tsuyoshi Igarashi', 'message': 'Hello' } return igarashi else: igarashi = { 'id': 1, 'author': 'Tuyoshi Igarashi', 'message': 'Hello' } miyayama = { 'id': 2, 'author': 'Ryutaro Miyayama', 'message': 'Looks good to me' } greetings = [igarashi, miyayama] 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 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