Cherrypy setup questions
Brian Blais
bblais at bryant.edu
Wed May 23 09:11:32 EDT 2007
fumanchu wrote:
> On May 22, 6:38 pm, Brian Blais <bbl... at bryant.edu> wrote:
>> 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.quickstart"
> function, supply the "base url" in the "script_name" argument; for
> example:
>
> sn = 'http://www.provider.com:8080/~myusername/apps'
> cherrypy.quickstart(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,*another):
if not another:
return("hello")
else:
return("hello: %s" % str(another))
@expose
def index(self):
return "Hello world!"
# at first I tried
cherrypy.quickstart(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.quickstart(HelloWorld(),baseurl)
# then
baseurl='http://localhost:8080/bblais/apps'
cherrypy.quickstart(HelloWorld(),baseurl)
# finally,
root=HelloWorld()
cherrypy.tree.mount(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.conf', where hello.conf is:
[global]
server.socket_host = "localhost"
server.socket_port = 8080
server.thread_pool = 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 at bryant.edu
http://web.bryant.edu/~bblais
More information about the Python-list
mailing list