| Newsgroups |
gmane.comp.python.cherrypy |
| Message-ID |
<[email protected]> |
When I run this example from the docs
<http://docs.cherrypy.org/en/latest/advanced.html?highlight=wsgi#no-need-for-the-wsgi-interface>
in unchanged form, then accessing http://localhost:8080/ from browser
produces the errors given below. Is there a mistake in this CherryPy
documentation code? (Section 'No need for the WSGI interface?') Thanks!
If your application is a pure CherryPy application, you can switch to a
HTTP server that by-passes the WSGI layer altogether. It will provide a
slight performance increase.
# File nowsgi.py
import cherrypy
class Root(object):
@cherrypy.expose
def index(self):
return "Hello World!"
if __name__ == '__main__':
from cherrypy._cpnative_server import CPHTTPServer
cherrypy.server.httpserver = CPHTTPServer(cherrypy.server)
cherrypy.quickstart(Root(), '/')
$ python nowsgi.py
[23/Nov/2015:15:10:06] ENGINE Listening for SIGUSR1.
[23/Nov/2015:15:10:06] ENGINE Listening for SIGHUP.
[23/Nov/2015:15:10:06] ENGINE Listening for SIGTERM.
[23/Nov/2015:15:10:06] ENGINE Bus STARTING
CherryPy Checker:
The Application mounted at '' has an empty config.
[23/Nov/2015:15:10:06] ENGINE Started monitor thread 'Autoreloader'.
[23/Nov/2015:15:10:06] ENGINE Started monitor thread '_TimeoutMonitor'.
[23/Nov/2015:15:10:06] ENGINE Serving on http://127.0.0.1:8080
[23/Nov/2015:15:10:06] ENGINE Bus STARTED
[23/Nov/2015:15:10:11] NATIVE_ADAPTER Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/cherrypy/_cpnative_server.py",
line 27, in respond
sn = cherrypy.tree.script_name(req.uri or "/")
File "/usr/lib/python3.5/site-packages/cherrypy/_cptree.py", line 257, in
script_name
path = path[:path.rfind("/")]
TypeError: a bytes-like object is required, not 'str'
ValueError('invalid literal for int() with base 10: "b\'5"',)
Traceback (most recent call last):
File "/usr/lib/python3.5/site-packages/cherrypy/_cpnative_server.py",
line 27, in respond
sn = cherrypy.tree.script_name(req.uri or "/")
File "/usr/lib/python3.5/site-packages/cherrypy/_cptree.py", line 257, in
script_name
path = path[:path.rfind("/")]
TypeError: a bytes-like object is required, not 'str'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File
"/usr/lib/python3.5/site-packages/cherrypy/wsgiserver/wsgiserver3.py", line
1068, in communicate
req.respond()
File
"/usr/lib/python3.5/site-packages/cherrypy/wsgiserver/wsgiserver3.py", line
856, in respond
self.server.gateway(self).respond()
File "/usr/lib/python3.5/site-packages/cherrypy/_cpnative_server.py",
line 88, in respond
self.send_response(s, h, b)
File "/usr/lib/python3.5/site-packages/cherrypy/_cpnative_server.py",
line 101, in send_response
req.send_headers()
File
"/usr/lib/python3.5/site-packages/cherrypy/wsgiserver/wsgiserver3.py", line
912, in send_headers
status = int(self.status[:3])
ValueError: invalid literal for int() with base 10: "b'5"
^C[23/Nov/2015:15:10:13] ENGINE Keyboard Interrupt: shutting down bus
[23/Nov/2015:15:10:13] ENGINE Bus STOPPING
[23/Nov/2015:15:10:13] ENGINE HTTP Server
cherrypy._cpnative_server.CPHTTPServer(('127.0.0.1', 8080)) shut down
[23/Nov/2015:15:10:13] ENGINE Stopped thread '_TimeoutMonitor'.
[23/Nov/2015:15:10:13] ENGINE Stopped thread 'Autoreloader'.
[23/Nov/2015:15:10:13] ENGINE Bus STOPPED
[23/Nov/2015:15:10:13] ENGINE Bus EXITING
[23/Nov/2015:15:10:13] ENGINE Bus EXITED
[23/Nov/2015:15:10:13] ENGINE Waiting for child threads to terminate...
--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
Visit this group at http://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.