def index(): blog = blogs.all(); form = BlogsForm(); if request.method == 'POST': flag = form.validate(request.params) if flag: n = blogs(**form.data); n.username = request.user.username n.save(); return {'blog':blog,'form':form}
def info(): if request.method == 'POST': new_user = blogs() new_user.username = request.form['user_name'] new_user.content = request.form['content'] new_user.title = request.form['title'] new_user.save() return redirect('/') else: posts = blogs.select().order_by(blogs.posttime.desc()) return render_template("home.html", posts=posts)
def create(): if require_login(): return redirect(url_for(login)) if request.method == "POST": form = BlogsForm() flag = form.validate(request.params) if flag: info = blogs(**form.data) info.username = request.user.username info.save() return redirect('/view/%d' % info.id) form = BlogsForm() return {'form':form}