Forums

Setting up CherryPy

I am trying to set up for running a CherryPy app. This is my /var/ww/wsgi.py :

import sys
sys.stdout = sys.stderr

import atexit
import threading
import cherrypy

cherrypy.config.update({'environment': 'embedded'})

if cherrypy.__version__.startswith('3.0') and cherrypy.engine.state == 0:
    cherrypy.engine.start(blocking=False)
    atexit.register(cherrypy.engine.stop)

class Root(object):
    def index(self):
        return 'Hello World!'
    index.exposed = True

application = cherrypy.Application(Root(), script_name=None, config=None)

This gives mes the following error though:


Unrecoverable error in the server. Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/CherryPy-3.2.2-py2.7.egg/cherrypy/_cprequest.py", line 571, in run self.script_name = self.app.script_name File "/usr/local/lib/python2.7/site-packages/CherryPy-3.2.2-py2.7.egg/cherrypy/_cptree.py", line 83, in _get_script_name return cherrypy.serving.request.wsgi_environ['SCRIPT_NAME'].rstrip("/") KeyError: 'SCRIPT_NAME'


Any help would be appreciated.

Thanks, Tom

Try changing

application = cherrypy.Application(Root(), script_name=None, config=None)

to

application = cherrypy.Application(Root(), script_name='', config=None)

@bavaria_multi: Welcome to PA. I hope you have a Cherry of a time here...☺

Thanks very much! That did the trick :-)