static file doc not work

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

static file doc not work

gasolin@gmail.com

Hi:

I found the doc "Serving static content with CherryPy 3" in cherrypy
wiki,
http://www.cherrypy.org/wiki/StaticContent

the syntax

    cherrypy.quickstart(Root(), '/', config=conf)

is not valid in CP3-rc1

I'll be appreciate if there's a correct guide.


regards

--
Fred


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: static file doc not work

Robert Brewer
[hidden email] wrote:
> I found the doc "Serving static content with CherryPy 3"
> in cherrypy wiki, http://www.cherrypy.org/wiki/StaticContent
> the syntax
>     cherrypy.quickstart(Root(), '/', config=conf)
> is not valid in CP3-rc1

Looks valid to me. Can you elaborate?


Robert Brewer
System Architect
Amor Ministries
[hidden email]

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


winmail.dat (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: static file doc not work

gasolin@gmail.com

Hi:

I found if I did the 3 step server start, to access
http://localhost:8080/static,
it returns : "The path '/static' was not found".


if __name__ == '__main__':

    current_dir = os.path.dirname(os.path.abspath(__file__))
    cherrypy.config.update({'environment': 'production','log.screen':
True})
    conf = {'/static' :
               {'cherrypy.tools.staticdir.on' : True,
                'cherrypy.tools.staticdir.dir' :
os.path.join(current_dir,
         'static')}}
    root = Root()
    cherrypy.tree.mount(root)
    cherrypy.server.quickstart()
    cherrypy.engine.start()


Did I missed something?


--
Fred


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: static file doc not work

Christian Wyglendowski-2

On 12/20/06, [hidden email] <[hidden email]> wrote:

>
> Hi:
>
> I found if I did the 3 step server start, to access
> http://localhost:8080/static,
> it returns : "The path '/static' was not found".
>
>
> if __name__ == '__main__':
>
>     current_dir = os.path.dirname(os.path.abspath(__file__))
>     cherrypy.config.update({'environment': 'production','log.screen':
> True})
>     conf = {'/static' :
>                {'cherrypy.tools.staticdir.on' : True,
>                 'cherrypy.tools.staticdir.dir' :
> os.path.join(current_dir,
>          'static')}}
>     root = Root()
>     cherrypy.tree.mount(root)
>     cherrypy.server.quickstart()
>     cherrypy.engine.start()
>
>
> Did I missed something?

It looks like you are defining a config (conf) but not passing it to
mount().  Try:

cherrypy.tree.mount(root, config=conf)

HTH,

Christian

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: static file doc not work

Robert Brewer
In reply to this post by gasolin@gmail.com
[hidden email] wrote:
> conf = {'/static' :
>         {'cherrypy.tools.staticdir.on': True,
>          'cherrypy.tools.staticdir.dir': ...

Short answer:
...when declared in config, the keys are just "tools.staticdir.*", not "cherrypy.tools.staticdir.*".

Longer answer:
Config keys get split on ".", and the first atom is used to find a config handler for that namespace. So only config keys that start with "tools." will get passed to the "tools" namespace handler.

Plus what Christian said.

Hope that helps!


Robert Brewer
System Architect
Amor Ministries
[hidden email]

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


winmail.dat (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: static file doc not work

Robert Brewer
In reply to this post by gasolin@gmail.com

[hidden email] wrote:

> I found if I did the 3 step server start, to access
> http://localhost:8080/static,
> it returns : "The path '/static' was not found".
>
> if __name__ == '__main__':
>
>     current_dir = os.path.dirname(os.path.abspath(__file__))
>     cherrypy.config.update({'environment': 'production','log.screen':
> True})
>     conf = {'/static' :
>                {'cherrypy.tools.staticdir.on' : True,
>                 'cherrypy.tools.staticdir.dir' :
> os.path.join(current_dir,
>          'static')}}
>     root = Root()
>     cherrypy.tree.mount(root)
>     cherrypy.server.quickstart()
>     cherrypy.engine.start()

FYI, both of those issues now raise a warning by default (turn off
production mode to run the checker on startup).


Robert Brewer
System Architect
Amor Ministries
[hidden email]


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: static file doc not work

gasolin@gmail.com

Thanks, now it works with

conf = {........."tools.staticdir.*}
cherrypy.tree.mount(root, config=conf)


Another case if I want to use "config.update" to infrom the static file
location, it fails:

conf = {........."tools.staticdir.*}

cherrypy.config.update(conf)
cherrypy.tree.mount(root)
cherrypy.server.quickstart()
cherrypy.engine.start()

Thanks for your respnse :-)


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---