def index(request): """ todo 首页的路由函数 """ u = current_user(request) key = 'completed' if key in request.query: # 只能手动判断,因为 bool(str(False)) == True if request.query[key] == 'true': index_completed = True else: index_completed = False todos = Todo.all(user_id=u.id, completed=index_completed) if index_completed: active_index = 'completed' else: active_index = 'uncompleted' else: todos = Todo.all(user_id=u.id) active_index = 'index' log('todo index', active_index) uncompleted = len(Todo.all(completed=False)) return html_response('todo_index.html', todos=todos, active_index=active_index, uncompleted=uncompleted)
def all(request): """ 返回所有 todo """ todo_list = Todo.all() todos = [t.json() for t in todo_list] return json_response(todos)
def index(): # 查找所有的 todo 并返回 log('args', request.args) todo_list = Todo.all() # flask 已经配置好了 jinja2 模板引擎 # 并且可以直接使用 render_template 来生成响应数据(http_response) return render_template('todo_index.html', todos=todo_list)
def index(request): """ todo 首页的路由函数 """ u = current_user(request) todos = Todo.all(user_id=u.id) return html_response('todo_index.html', todos=todos)
def index(): """ todo 首页的路由函数 """ u = current_user() todos = Todo.all(user_id=u.id) # 替换模板文件中的标记字符串 return render_template('todo_index.html', todos=todos)
def index(request): result = request.query.get('result', '') result = unquote_plus(result) u = current_user(request) todos = Todo.all() # 替换模板文件中的标记字符串 body = Template.render('todo_index.html', todos=todos, result=result) return html_response(body)
def todos(self): # 列表推倒和过滤 # return [t for t in Todo.all() if t.user_id == self.id] ts = [] for t in Todo.all(): if t.user_id == self.id: ts.append(t) return ts
def all(request): """ 返回所有 routes """ todo_list = Todo.all() # 要转换为 dict 格式才行 todos = [t.json() for t in todo_list] return json_response(todos)
def all(): """ 返回所有 todo """ todo_list = Todo.all() # 要转换为 dict 格式才行 todos = [t.json() for t in todo_list] return jsonify(todos)
def all(request): """ 返回 json 格式的所有 todo 数据 """ u = current_user(request) todos = Todo.all(user_id=u.id) todos = [todo.to_dict() for todo in todos] return json_response(todos)
def all(request): """ 返回所有 todo """ todos = Todo.all() # 要转换为 dict 格式才行 todos = [t.json() for t in todos] return json_response(todos)
def all(request): """ 返回所有的todo :param request: :return: json格式数据 """ todo_list = Todo.all() # 把todo对象转化成字典 todos = [t.json() for t in todo_list] return json_response(todos)
def index(): # 查找所有的 todo 并返回 todo_list = Todo.all() request.method log("args", request.args) # [] # todos = todolist # flask 已经配置好了 jinja2 模板引擎 # 并且可以直接使用 render_template 来生成响应数据(http_response) return render_template('todo_index.html', todos=todo_list)
def index(request): """ todo 首页的路由函数 """ # u = current_user(request) # todos = Todo.find_all(user_id=u.id) todos = Todo.all() # 替换模板文件中的标记字符串 body = JinjaTemplateRender.render('todo_index.html', todos=todos) return html_response(body)
def all_task(): u = current_user() ts = Todo.all(user_id=u.id) response = [] for t in ts: d = dict( id=t.id, task=t.task, done=t.done, ) response.append(d) # print('response', response) return jsonify(response)
def index(): # 查找所有的 routes 并返回 todo_list = Todo.all() # flask 已经配置好了 jinjia2 模板引擎 # 并且可以直接使用 render_template 来生成相应数据(http_response) return render_template('todo_index.html', todos=todo_list)
def all_todo(request): todo_list = Todo.all() todos = [todo.json() for todo in todo_list] return json_response(todos)
def index(): # 查找所有的 todo 并返回 todo_list = Todo.all() # flask 已经配置好了 jinja2 模板引擎 # 并且可以直接使用 render_template 来生成响应数据(http_response) return render_template('todo_index.html', todos=todo_list, strtime=strtime)
def index(reqeust): todos = Todo.all() body = render_template('todo.html', todos=todos) r = http_response(body) return r
def index(request): todo_list = Todo.all() body = templates('simple_todo_index.html', todos=todo_list) return http_response(body)
def all(request): ts = [t.__dict__ for t in Todo.all()] return json_response(ts)
def todo_all(request): todo_list = Todo.all() todos = [t.json() for t in todo_list] return json_response(todos)
def index(): # 查找所有的 todo 并返回 todo_list = Todo.all() return render_template('todo/index.html', todos=todo_list)
def all(): u = current_user() todos = [t.json() for t in Todo.all(user_id=u.id)] return jsonify(todos)
def todo_complete(): todos = Todo.all(complete=True) return render_json(todos)
def index(): todo_list = Todo.all() return render_template('todo_index.html', todos=todo_list)
def todo_index(): log('all') todos = Todo.all() return render_json(todos)
def index(): todo_list = Todo.all() # request.method log("args", request.args) return render_template('todo_index.html', todos=todo_list)
def todo_uncomplete(): todos = Todo.all(complete=False) return render_json(todos)
def ajax_all(request): u = current_user(request) todos = Todo.all(user_id=u.id) todos = [t.__dict__ for t in todos] return json_response(todos)