Re: Setup Differnt Port for CherryPy

Michiel Overtoom <motoom-qWit8jRvyhVmR6Xm/[email protected]>
Newsgroups gmane.comp.python.cherrypy
Message-ID <[email protected]>
Hi Will,

You wrote:

> I am having trouble with setting CherryPy to a different port.

and the book said:

> If we would like CherryPy to listen on a different port, we should indicate this in the global configuration. This can be done by preceding the call to cherrypy.quickstart() with cherrypy.config.update({'server.socket_port':8088}).


So, your code becomes:


import cherrypy
import os.path

current_dir = os.path.dirname(os.path.abspath(__file__))

class Root(object):
    content = "<p>Hello there</p>"

    @cherrypy.expose
    def index(self):
        return Root.content


if __name__ == "__main__":
    cherrypy.config.update({
        "server.socket_port": 8088,
        })
    config = {
        "/static": {
            "tools.staticdir.on": True,
            "tools.staticdir.dir": current_dir + "/static",
            }
        }
    cherrypy.quickstart(Root(), "/", config)


Greetings,

-- 
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 https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.