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: 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 To: python list 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 --001a11c1b6489187de04da8eeaf2 Content-Type: text/plain; charset=UTF-8 *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('Reply Page') # html reply page if not 'user' in form: print('

Who are you?

') else: print('

Hello %s!

' % 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 Reply Page

Who are you?

*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?* --001a11c1b6489187de04da8eeaf2 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I installed tornado and he is functional, but when I= execute the following script:

import tornado.ioloop
impo= rt tornado.web
import cgi

class MainHandler(tornado.web.
Requ= estHandler):

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

application =3D tornado.web.Application([
=C2=A0=C2=A0=C2=A0 (r"= ;/", MainHandler),
])

if __name__ =3D=3D "__main__"= ;:
=C2=A0=C2=A0=C2=A0 application.listen(8888)
=C2=A0=C2=A0=C2=A0 tor= nado.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 loca= lhost: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?<= /b>
--001a11c1b6489187de04da8eeaf2--