def GET(self): if not session.get('logged_in', False): raise web.HTTPError("401 unauthorized", {}, "unauthorized") web.header('Content-Type', 'application/json') todos = model.get_todos() return json.dumps(todos.list())
def POST(self): form = self.form() if not form.validates(): todos = model.get_todos() return render.index(todos, form) model.new_todo(form.d.title) raise web.seeother('/')
def GET(self): """ Show page """ todos = model.get_todos( ) # returns an iterbetter object where u can iterate on it form = self.form() # returns a form object which prints html return render.index( todos, form) # print the index which contains todos and form
def POST(self): form=self.form() if not form.validates(): todos=model.get_todos() return render.index(todos, form) model.new_todo(form.d.title) raise web.seeother('/')
def POST(self): """ Add new entry """ form = self.form() if not form.validates(): # it is not validated todos = model.get_todos() # get the existing form return render.index(todos, form) # return the index page model.new_todo(form.d.title) # if validated, add todo raise web.seeother('/') # 303 redirect back (so it refreshes)
def GET(self): if session.get('logged_in', False): """ Show page """ todos = model.get_todos() form = self.form() return render.index(todos, form) else: raise web.seeother('/login')
def POST(self): """ Add new entry """ form = self.form() todos = model.get_todos() if not form.validates(): return render.index(todos, form) model.new_todo(form.d.title) raise web.seeother("/")
def GET(self, name): def default(o): return o.__dict__ todos = model.get_todos() if not name: name = 'World' return json.dumps(lista, default=default,indent=4)
def POST(self): """ Add new entry """ form = self.form() if not form.validates(): todos = model.get_todos() raise web.seeother('/') model.new_todo(form.d.title) raise web.seeother('/')
def GET(self): """ Show page """ if session.get('loggedin') == True: usrname = session.username todos = model.get_todos(usrname) return render.index(todos, usrname) else: return web.seeother('/')
def GET(self): """ Show page """ if session.get('loggedin')==True: todos = model.get_todos() usrname=session.username return render.index(todos, usrname) else: return web.seeother('/')
def POST(self): """ Add new entry """ form = self.form() if not form.validates(): todos = model.get_todos() return render.index(todos, form) model.new_todo(form.d.title) raise web.seeother(URL_ROOT)
def POST(self): '''Add new netry''' form = self.form() if not form.validates(): # 判断输入是否合法 todos = model.get_todos() # 如果输入不合法,将继续显示现有网页并由验证模块给出错误提示 return render.index(todos, form) # model.new_todo(form.d.title) # 合法即调用new_todo方法将数据写入数据库 raise web.seeother('/') # raise 关键字用于自定义异常处理,这里的作用是:不管怎样都将调用web.seeother('/')对页面进行跳转
def POST(self): """ Add new entry """ i=web.input() newtodo=i.addmore usrname=session.username todos = model.get_todos() render.index(todos, usrname) model.new_todo(newtodo,usrname) raise web.seeother('/index')
def POST(self): """ Add new entry """ i = web.input() newtodo = i.addmore usrname = session.username todos = model.get_todos(usrname) render.index(todos, usrname) model.new_todo(newtodo, usrname) raise web.seeother('/index')
def POST(self): '''Add new item''' form = self.form if not form.validates(): todos = model.get_todos() return render.index(todos,form) ip = web.ctx.ip model.new_todo(form.d.name,form.d.msg,ip) raise web.seeother('/nianyuguai')
def GET(self): '''Show Page''' # 获取IP # ip = web.ctx.ip # print ip # print path todos = model.get_todos() form = self.form() form.inputs[1].value = None return render.admin(todos,form)
def GET(self): '''Show Page''' # 获取IP # ip = web.ctx.ip # print ip # print path todos = model.get_todos() form = self.form() form.inputs[1].value = None # for input in : # print input.value # input.value = None # print input.value print form.get('msg') return render.index(todos,form)
def GET(self): """ Show page """ todos = model.get_todos() form = self.form() return render.index(todos, form)
def GET(self): todos = model.get_todos() form = self.form() return render.index(todos, form)
def GET(self): """show page""" todos = model.get_todos() todos = todos if todos else [] #Ternary operator --> assign todos the value of todos if todos is a non-null value else make an empty list form = self.form() return render.index(todos, form)
def GET(self): """ Show page """ todos = model.get_todos() return render.index(todos)
def GET(self): '''Show page''' todos = model.get_todos() # 通过model类的get_todos方法获取数据 form = self.form() # 引用前面实例化的form对象 return render.index(todos, form) # 将两个变量渲染到模版index网页中
def GET(self): debug = int(web.webapi.input(debug=0).debug) user = getUserbyIP() isqa = model.is_qa(user) todos = model.get_todos(debug) return render.index(todos, user, isqa, debug)
def GET(self): todos=model.get_todos() form=self.form() return render.index(todos, form)