示例#1
0
def post():
    '''New post submission.'''
    message = request.form['content']
    print((message, ))
    print('ENDERECO PARA A MAIN')
    print(url_for('main'))
    add_post(message)
    return redirect(url_for('main'))
示例#2
0
def post(env, resp):
    """Post handles a submission of the forum's form.
  
    The message the user posted is saved in the database, then it sends a 302
    Redirect back to the main page so the user can see their new post.
    """
    # Get post content
    input = env["wsgi.input"]
    length = int(env.get("CONTENT_LENGTH", 0))
    # If length is zero, post is empty - don't save it.
    if length > 0:
        postdata = input.read(length)
        fields = cgi.parse_qs(postdata)
        content = fields["content"][0]
        # If the post is just whitespace, don't save it.
        content = content.strip()
        if content:
            # Save it in the database
            forumdb.add_post(content)
    # 302 redirect back to the main page
    headers = [("Location", "/"), ("Content-type", "text/plain")]
    resp("302 REDIRECT", headers)
    return ["Redirecting"]
示例#3
0
def Post(env, resp):
    """Post handles a submission of the forum's form.
    The message the user posted is saved in the database, then it sends a 302
    Redirect back to the main page so the user can see their new post.
    """

    # Get post content
    wsgi_input = env['wsgi.input']
    length = int(env.get('CONTENT_LENGTH', 0))
    # If length is zero, post is empty - don't save it.
    if length > 0:
        postdata = wsgi_input.read(length)
        fields = cgi.parse_qs(postdata)
        content = fields['content'][0]
        # If the post is just whitespace, don't save it.
        content = content.strip()
        if content:
            # Save it in the database
            forumdb.add_post(content)
    # 302 redirect back to the main page
    headers = [('Location', '/'), ('Content-type', 'text/plain')]
    resp('302 REDIRECT', headers)
    return ['Redirecting']
示例#4
0
def post(env, resp):
    # Post handles a submission of the forum's form.
  
    # The message the user posted is saved in the database, then it sends a 302
    # Redirect back to the main page so the user can see their new post.

    # Get post content
    input = env['wsgi.input']
    length = int(env.get('CONTENT_LENGTH', 0))
    # If length is zero, post is empty - don't save it.
    if length > 0:
        postdata = input.read(length)
        fields = urlparse.parse_qs(postdata)
        content = fields['content'][0]
        # If the post is just whitespace, don't save it.
        content = content.strip()
        if content:
            # Save it in the database
            forumdb.add_post(content)
    # 302 redirect back to the main page
    headers = [('Location', '/'),
               ('Content-type', 'text/plain')]
    resp('302 REDIRECT', headers) 
    return ['Redirecting']
示例#5
0
def post():
    '''New post submission.'''
    message = request.form['content']
    add_post(message)

    return redirect(url_for('main'))
示例#6
0
def post():
  '''New post submission.'''
  message = request.form['content']
  better_message = bleach.clean(message)
  add_post(better_message)
  return redirect(url_for('main'))