Hi,<br><br>I am using web2 to run a cherrypy server at the root of the site using WSGI.<br><br>I've got a nearly working set up, the only problem is that when a request comes in for the root of the site, it gets redirected
<br>back to itself:<br>% curl <a href="http://localhost:8080">http://localhost:8080</a><br>This resource resides temporarily at <a href='<a href="http://localhost:8080/'">http://localhost:8080/'</a>><a href="http://localhost:8080/">
http://localhost:8080/</a></a><br><br>Intriguingly, if I request locations below the root, things work more OK:<br>% curl <a href="http://localhost:8080/test/index">http://localhost:8080/test/index</a><br><br>then it works OK, even though I am registering the cherrypy at the root of the site.
<br><br>I've experimented, and if I register the cherrypy site in a subdir, everything works normally as expected!<br><br>Here's the code that puts it at the root of the site. I've tested this code with a basic WSGI app,
<br>and it works OK. Only cherrypy seems to have this problem. One clue is that the logger shows<br>that the URL being requested is '//' instead of '/':<br><br>2007-03-18 19:07:02-0700 [HTTPChannel,6,<a href="http://127.0.0.1">
127.0.0.1</a>] <a href="http://127.0.0.1">127.0.0.1</a> - - [18/Mar/2007:19:07:02] "GET // HTTP/1.1" 302 97 "" "curl/7.15.1 (i686-suse-linux) libcurl/7.15.1 OpenSSL/0.9.8a zlib/1.2.3 libidn/0.6.0"
<br><br>Here's the nearly working test example:<br><br><br>from twisted.application import service, strports<br>from twisted.web2 import server, channel<br>from twisted.web2 import log<br>from twisted.web2 import wsgi
<br>from twisted.web2.wsgi import WSGIResource<br>from cherrypy._cpwsgi import wsgiApp<br>import cherrypy<br><br>## Basic cherrypy index object that dumps the WSGI environment<br>class Root(object):<br> @cherrypy.expose
<br> def index(self):<br> s = []<br> for key in cherrypy.request.wsgi_environ:<br> s.append("%s=%s<br/>" % (key, cherrypy.request.wsgi_environ[key]))<br><br> return "".join(s)
<br><br>## Run this site using "twistd -noy"<br>if __name__ == '__builtin__':<br><br> ## Create an instance of the root object and mount it at /<br> r = Root()<br> cherrypy.tree.mount(r, '/')
<br> wsgi = wsgi.WSGIResource(wsgiApp)<br><br> ## Set up the cherrypy environment<br> cherrypy.config.update({<br> 'server.environment':'production',<br> 'server.socketHost':'
<a href="http://127.0.0.1">127.0.0.1</a>',<br> })<br><br> ## Start the cherrypy server; don't actually run an HTTP server, though<br> cherrypy.server.start(initOnly=True, serverClass=None)<br><br> ## Setup default common access logging
<br> res = log.LogWrapperResource(wsgi)<br> log.DefaultCommonAccessLoggingObserver().start()<br><br> # Create twisted web2 site<br> site = server.Site(res)<br> application = service.Application("demo")
<br><br> ## Launch the HTTP site at port 8080<br> s = strports.service('tcp:8080', channel.HTTPFactory(site))<br> s.setServiceParent(application)<br> <br><br>