Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #43760

Tornado with cgi form

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post2.news.xs4all.nl!not-for-mail
Return-Path <renato.barbosa.pim.pereira@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.012
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'else:': 0.03; 'subject:form': 0.07; '"__main__":': 0.09; '__name__': 0.09; 'python': 0.11; "'user'": 0.16; 'subject:Tornado': 0.16; 'to:name:python list': 0.16; 'fix': 0.17; 'import': 0.22; 'this?': 0.23; 'error': 0.23; 'form:': 0.24; 'parse': 0.24; 'this:': 0.26; 'installed': 0.27; 'idea': 0.28; 'skip:p 30': 0.29; 'message- id:@mail.gmail.com': 0.30; 'you?': 0.31; 'cgi': 0.31; 'class': 0.32; 'skip:c 30': 0.32; 'skip:& 30': 0.33; 'skip:t 40': 0.33; 'received:74.125.82': 0.34; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'method': 0.36; 'application': 0.37; 'skip:& 10': 0.38; 'skip:m 40': 0.38; 'to:addr:python-list': 0.38; 'skip:& 20': 0.39; 'received:74.125': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'blank': 0.60; 'skip:c 50': 0.60; 'browser': 0.61; 'reply': 0.66
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=nZ7EnPHm6Ckr/p6ksBbs1jsZNv8lOVdgrJHC05qZJW4=; b=k3pD1mRXBcC23ZQMqrjIMokq7JZRSrayctWL2EU93QHFcX9j4q3tUNLmk9aXQ4pJES 3xyCbqGQc8cu70xP1YKoGHZDTFZvnc7DdsWzvOSV19Ftyd3oT5kKH0XIRfQBlFGk0gve wR7d8ARV8Ix4DWVuJk16kQxpSW9evnczOibKy6ubCGsBMX9ONePqFJ+lmTEqARTzTTIp OmycD6uDA4f/5ZamoW5EU/qBptT7BRDniN5yfa6AavTsNY4dlaM6dVXjUtq7OQRDPtzi kdgQX8jMEJNTsa3wZc1xMCQYOUWSwvzChoWwKQfPRKj4OUn3vDbz7jWOwNe2X4QBWHM7 egkA==
MIME-Version 1.0
X-Received by 10.194.220.37 with SMTP id pt5mr11677659wjc.16.1366207262457; Wed, 17 Apr 2013 07:01:02 -0700 (PDT)
Date Wed, 17 Apr 2013 11:01:02 -0300
Subject Tornado with cgi form
From Renato Barbosa Pim Pereira <renato.barbosa.pim.pereira@gmail.com>
To python list <python-list@python.org>
Content-Type multipart/alternative; boundary=001a11c1b6489187de04da8eeaf2
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.724.1366207448.3114.python-list@python.org> (permalink)
Lines 80
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366207448 news.xs4all.nl 2200 [2001:888:2000:d::a6]:47965
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:43760

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

*I installed tornado and he is functional, but when I execute the following
script:*

import tornado.ioloop
import tornado.web
import cgi

class MainHandler(tornado.web.
RequestHandler):

    form = cgi.FieldStorage()                 # parse form data
    print('Content-type: text/html\n')        # hdr plus blank line
    print('<title>Reply Page</title>')        # html reply page
    if not 'user' in form:
            print('<h1>Who are you?</h1>')
    else:
            print('<h1>Hello <i>%s</i>!</h1>' %
cgi.escape(form['user'].value))

application = tornado.web.Application([
    (r"/", MainHandler),
])

if __name__ == "__main__":
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()

*In the terminal have these outputs:*

python test.py
Content-type: text/html

<title>Reply Page</title>
<h1>Who are you?</h1>

*When I call the browser on localhost:8888, the message is this:*

405: Method Not Allowed
*
**Please, can someone have a idea about why the error occurs? and what I
need to do to fix this?*

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Tornado with cgi form Renato Barbosa Pim Pereira <renato.barbosa.pim.pereira@gmail.com> - 2013-04-17 11:01 -0300

csiph-web