Cherrypy setup questions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brian Blais

    #1

    Cherrypy setup questions

    Hello,

    I'd like to start trying out some cherrypy apps, but I've been having some setup
    problems. I think I need some bone-head simple example to clear my understanding. :)

    I'm on a system running Apache, that I don't have root access to. I will be
    publishing the html/image/python files in a directory off of my current web page, and
    running the app as a user on the system. I'd like to be able to specify the base url
    for the app, especially if I have more than one app. I've read the docs, but am
    getting confused with the config file information, and exactly how to set it up. I'm
    using CherryPy 3.0.1, the latest I know.

    Some questions I have:
    1) can I configure cherrypy to look at requests only off a base url, like:



    and ignore all other requests below that url, like



    or




    2) If you run (as in Unix):

    cd app1
    python mycherrypyapp1. py &

    cd ../app2
    python mycherrypyapp2. py &


    Does this start 2 cherrypy servers, trying to both fight for port 8080, or is there
    only one, and the two apps share it?


    Are there any examples that show such a setup? I didn't see a CherryPy mailing list,
    so I'm posting here, but if there is somewhere else better I'd be glad to know!




    thanks,


    Brian Blais


    --
    -----------------

    bblais@bryant.e du

  • fumanchu

    #2
    Re: Cherrypy setup questions

    On May 22, 6:38 pm, Brian Blais <bbl...@bryant. eduwrote:
    I'd like to start trying out some cherrypy apps, but I've
    been having some setup problems. I think I need some
    bone-head simple example to clear my understanding. :)
    >
    I'm on a system running Apache, that I don't have root
    access to. I will be publishing the html/image/python
    files in a directory off of my current web page, and
    running the app as a user on the system. I'd like to be
    able to specify the base url for the app, especially if
    I have more than one app. I've read the docs, but am
    getting confused with the config file information, and
    exactly how to set it up. I'm using CherryPy 3.0.1,
    the latest I know.
    >
    Some questions I have:
    1) can I configure cherrypy to look at requests only
    off a base url, like:
    >
    http://www.provider.com:8080/~myusername/apps
    Yes, you can. Assuming you're using the "cherrypy.quick start"
    function, supply the "base url" in the "script_nam e" argument; for
    example:

    sn = 'http://www.provider.co m:8080/~myusername/apps'
    cherrypy.quicks tart(Root(), sn, config)

    If you're using cherrypy.tree.m ount instead of quickstart, it takes a
    similar argument.
    2) If you run (as in Unix):
    >
    cd app1
    python mycherrypyapp1. py &
    >
    cd ../app2
    python mycherrypyapp2. py &
    >
    Does this start 2 cherrypy servers, trying to both fight
    for port 8080, or is there only one, and the two apps share it?
    This will almost certainly start two cherrypy servers. You can run one
    on a different port via a "server.socket_ port" config entry if you
    like. If you want them both to run on the same port but different
    "base urls", you should write a small "mysite.py" which mounts them as
    desired; for example:

    # mysite.py

    import cherrypy
    import app1, app2

    cherrypy.tree.m ount(app1.root, "/app1")
    cherrypy.tree.m ount(app2.root, "/app2")
    cherrypy.server .quickstart()
    cherrypy.engine .start()
    cherrypy.engine .block()

    I didn't see a CherryPy mailing list, so I'm posting here,
    but if there is somewhere else better I'd be glad to know!
    There is a cherrypy-users mailing list, and I'm CC'ing it so you can
    reply there if you like. :)

    Hope that helps!


    Robert Brewer
    System Architect
    Amor Ministries
    fumanchu@amor.o rg

    Comment

    • Brian Blais

      #3
      Re: Cherrypy setup questions

      fumanchu wrote:
      On May 22, 6:38 pm, Brian Blais <bbl...@bryant. eduwrote:
      >I'd like to start trying out some cherrypy apps, but I've
      >been having some setup problems. I think I need some
      >bone-head simple example to clear my understanding. :)
      >1) can I configure cherrypy to look at requests only
      >off a base url, like:
      >>
      > http://www.provider.com:8080/~myusername/apps
      >
      Yes, you can. Assuming you're using the "cherrypy.quick start"
      function, supply the "base url" in the "script_nam e" argument; for
      example:
      >
      sn = 'http://www.provider.co m:8080/~myusername/apps'
      cherrypy.quicks tart(Root(), sn, config)
      >
      Thanks for your reply, but for some reason it is not working as stated. I'm probably
      missing something.

      import cherrypy
      from cherrypy import expose

      class HelloWorld:


      @expose
      def hello(self,*ano ther):
      if not another:
      return("hello")
      else:
      return("hello: %s" % str(another))


      @expose
      def index(self):
      return "Hello world!"


      # at first I tried
      cherrypy.quicks tart(HelloWorld ())

      which works, off of http://localhost:8080/

      and http://localhost:8080/hello
      and http://localhost:8080/hello/more_stuff

      works fine.

      # so then I tried each of these (separately, of course)...
      baseurl='http://localhost:8080/~bblais/apps'
      cherrypy.quicks tart(HelloWorld (),baseurl)

      # then
      baseurl='http://localhost:8080/bblais/apps'
      cherrypy.quicks tart(HelloWorld (),baseurl)


      # finally,
      root=HelloWorld ()
      cherrypy.tree.m ount(root,'apps/')
      cherrypy.server .quickstart()
      cherrypy.engine .start()
      cherrypy.engine .block()


      In each case, there is similar behavior. The script runs fine, and the Cherrypy
      gives the usual startup message, but nothing is printed when I access the above urls.
      I know something is wrong, because cherrypy doesn't even log the events. Without
      the baseurl specified, I get things like:

      127.0.0.1 - - [23/May/2007:08:56:24] "GET /hello HTTP/1.1" 200 5 "" ""

      whenever I access the site. Specifying the baseurl, nothing.

      Two more pieces of info. When I start, I usually get:

      The Application mounted at '' has an empty config.

      which is solved by adding a config='hello.c onf', where hello.conf is:

      [global]
      server.socket_h ost = "localhost"
      server.socket_p ort = 8080
      server.thread_p ool = 10


      even with that, I when I specify a baseurl (say, apps), I get:

      The Application mounted at 'apps' has an empty config.


      Is it missing something, that it can't make a default choice on?



      thanks for your help!


      Brian Blais


      --
      -----------------

      bblais@bryant.e du


      Comment

      Working...