def GET(web): """ This shows how to do a simple database setup. You can also just import the db inside the .html file if you want and don't need to go to a handler first. """ if web.sub_path == '/delete': db.delete('test', where='id = $id', vars=web.params) return render("showdb.html", web)
def GET(web): """ This shows how to do a simple database setup. You can also just import the db inside the .html file if you want and don't need to go to a handler first. """ if web.sub_path == "/delete": db.delete("test", where="id = $id", vars=web.params) return render("showdb.html", web)
def run(web): post_id = web.sub_path[1:] if not post_id: return error(404, "Not Found") web.post = db.get('post', by_id=post_id) if web.post: return render('show_post.html', web) else: return error(404, "Not Found")
def process(method, path, params, context): if not csrf_check(context): return render_error(404, "Not Found") try: return render(path, context) except TemplateNotFound: print "Jinja2 template missing in path: %r for context %r" % (path, context) traceback.print_exc() return render_error(404, "Not Found") except Exception as e: traceback.print_exc() return render_error(500, str(e))
def GET(web): """ Demonstrates using the session and also how to then render another thing seamlessly. Just call web.app.render() and it'll do all the resolving gear again, so one method works on statics, modules, jinja2 just like you accessed it from a browser. """ web.form = forms.read(web, reset=False) if web.form.reset: web.session['count'] = 1 else: web.session['count'] = web.session.get('count', 1) + 1 return render('renderme.html', web)
def GET(web): return render("write_post.html", web)