@bp.route("<STR_LIT>", methods=("<STR_LIT:GET>", "<STR_LIT:POST>"))<EOL>@login_required<EOL>def create():
if request.method == "<STR_LIT:POST>":<EOL><INDENT>title = request.form["<STR_LIT:title>"]<EOL>body = request.form["<STR_LIT:body>"]<EOL>error = None<EOL>if not title:<EOL><INDENT>error = "<STR_LIT>"<EOL><DEDENT>if error is not None:<EOL><INDENT>flash(error)<EOL><DEDENT>else:<EOL><INDENT>db.session.add(Post(title=title, body=body, author=g.user))<EOL>db.session.commit()<EOL>return redirect(url_for("<STR_LIT>"))<EOL><DEDENT><DEDENT>return render_template("<STR_LIT>")<EOL>
Create a new post for the current user.