473,763 Members | 7,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Running twisted http server - "Method Not Allowed" error

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.interne t import reactor

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

site = server.Site(Sim ple())
reactor.listenT CP(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>40 5 - Method Not Allowed</title></head>
<body><h1>Metho d 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
1 5902
On 30 May 2005 23:50:45 -0700, qw*****@hotmail .com wrote:
from twisted.web import server, resource
from twisted.interne t import reactor

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

site = server.Site(Sim ple())
reactor.listenT CP(8080, site)
reactor.run() "


Try adding the line:

allowedMethods = ('GET',)

after the line

isLeaf = True

--
Richard
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1921
by: Roy Smith | last post by:
I had a class called rule and a subclass of rule, called bgpRule, in a file called bgp.py. I decided to move the rule class to its own file, called rule.py. The original file did "import rule". I forgot to change bgpRule's __init__() method from calling rule.__init__() to call rule.rule.__init__(). Amazingly, this caused no immediate error, but rule.__init__() never got called. When I found the problem, I was puzzled as to why I...
1
35135
by: Tim C. | last post by:
I get the error "error executing child request" when I use the Server.Transfer method to invoke a second aspx page. The following code is executed in a LinkButton click eventhandler on Page1.aspx. Server.Transfer("Page2.aspx",True) This code is virtually identical to the examples in chapter 4 (p. 196) of Microsoft's _Developing Web Applications_ 2nd edition, by Jeff Web. For what I'm
1
2553
by: Kris | last post by:
Hey everyone, I am trying to make a multi-project web application in visual studio that uses the server.transfer method in C# to get to the different aspx pages. However, when I call out to the page it gives me the Could not load type "MainConsole.Default". The code was working before when i had it all in one project. I want to seperate the one big project and create little ones to communicate to each other, just like a desktop
0
1051
by: ttomic | last post by:
I have asp.net application written in jscript. On POST request, during Page_Load, I receive string which I evaluate using jscript eval method. String looks like: my_fun("arg") where my_fun is some method in aspx. body of my_fun looks like: function my_fun(s:String) : String { var v:Typ0 = new Typ0();
1
2116
by: Eric | last post by:
I created a simple web site in VS 2005 and then copied it underneath the IIS tree and created a virtual directory for it. When I try to access the default.aspx page I get the below error text: Note that this is the default web.config file generated by the application. The OS is Windows Server 2003, released version of VS 2005, created an Asp.Net file system web site that does not do anything special and deployed it to test.
5
50737
by: rk325 | last post by:
Yes, I've seen many posts about this type of error, and none of the solutions people applied worked for me. So please read this one carefully and help me if you can. I have a web service application installed in a Windows 2000 SP4 Domain control server. It is running IIS 5.0. I can access the WS from its own web page, and, when I access it from the server where it is installed, I can run its methods. However, I cannot access this WS...
5
27704
by: MichaelK | last post by:
What do I need to do to enable CDONTS om my macine to make it working I'm testing the code: Dim objCDO Set objCDO = Server.CreateObject("CDONTS.NewMail") objCDO.To = "xyz@xxxxx.com" objCDO.From = "zyx@zzzzz.com" objCDO.Subject = "TESST CDONTS MAIL" objCDO.Body = "SOME TEXT TO SEND OVER"
6
6313
by: placid | last post by:
Hi all, Ive been reading about creating a HTTP server like the one pydoc creates (and studying pydoc source code). What i want to know, is it possible to create server that creates a webpage with hyperlinks that communicate back to the HTTP server, where each link accessed tells the server to execute some arbitrary command on local machine its running on? Cheers
3
4933
by: J055 | last post by:
Hi How do I tell the user he has tried to upload a file which is too big... 1. when the httpRuntime.maxRequestLength has been exceeded and 2. when the uploaded file is under then httpRuntime.maxRequestLength For point 1. it would be good to at least display a nice error page. IE seems to just display a blank page.
0
9386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10144
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9997
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9822
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8821
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.