By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,512 Members | 3,689 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,512 IT Pros & Developers. It's quick & easy.

Running twisted http server - "Method Not Allowed" error

P: n/a
Hello,

I had posted this question in the twisted mailing list but did not
got a solution ; I hope that the python Gurus of this forum can help me
a bit.

I am trying the exmaple in the python docs -
http://twistedmatrix.com/users/warne...istedweb.xhtml

Configuring and Using the Twisted.Web Server - Twisted Web Development.

it says there:

"You can also create a Site instance by hand, passing it a Resource
object which will serve as the root of the site:

from twisted.web import server, resource
from twisted.internet import reactor

class Simple(resource.Resource):
isLeaf = True
def render_GET(self, request):
return "<html>Hello, world!</html>"

site = server.Site(Simple())
reactor.listenTCP(8080, site)
reactor.run() "

So I prepared a script named myhttp exactly like this and ran ./myhttp

I had made sure with netstat that indeed port 8080 was free before
running the script and after
running the script it was in a listening state.

But when pointing the Mozilla browser to http://localhost:8080 (or
http://127.0.0.1:8080)
I got the following error:

"Method Not Allowed
Your browser approached me (at /) with the method "GET". I only allow
the method here."

I had also made sure that there in no problem with iptables and that
the iptable service is down.

I had also tried:
telnet localhost 8080
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET / HTTP/1.0

And I got this as a response:

HTTP/1.0 405 Method Not Allowed
Date: Tue, 31 May 2005 13:45:29 GMT
Content-length: 242
Content-type: text/html
Allow: ()
Server: TwistedWeb/2.0.0

<html>
<head><title>405 - Method Not Allowed</title></head>
<body><h1>Method Not Allowed</h1>
<p>Your browser approached me (at /) with the method "GET".
I only
allow the method here.</p>
</body></html>

Connection closed by foreign host.
Tracing this error shows that this it stems from twisted/web/server.py.
I also tried it on a second machine with the latest stable releases
(TwistedWeb-0.5.0, Twisted-2.0.1 , Python-2.4.1, and
ZopeInterface-3.0.1)
and I got the same error.

I am trying it on RedHat 9 Linux (x386 based).

Any idea ?

Am I missing something?
Any help will be appreciated.

Regards,
John

Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 30 May 2005 23:50:45 -0700, qw*****@hotmail.com wrote:
from twisted.web import server, resource
from twisted.internet import reactor

class Simple(resource.Resource):
isLeaf = True
def render_GET(self, request):
return "<html>Hello, world!</html>"

site = server.Site(Simple())
reactor.listenTCP(8080, site)
reactor.run() "


Try adding the line:

allowedMethods = ('GET',)

after the line

isLeaf = True

--
Richard
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.