On Wed, 2011-01-05 at 10:23 -0800, Dominik wrote: > Hi Chris, > > > We have a "cookbook" in the works that describes how to do something > > like this. Here's a sneak peek: > > > > http://plope.com/static/pyramid_cookbook/static.html#root-relative-cu... > > Yes, thanks - I found something similar in the "Serving Static Assets" > documentation [1]. However, if I understood correctly, this still > wouldn't help for the standard case of responding to request to "/" > with the static "index.html", like apache does for example for > index.htm(l)/php/cgi etc. Any ideas?
Ah, right, no, it doesn't. For that, create a view. import os from pyramid import Response def my_view(request): here = os.path.dirname(__file__) index_html = os.path.join(here, 'index.html') data = index_html.read() return Response(data, content_type='text/html') And configure it in to your site as /: add_route('home', '/', view='my_view') Put a file named index.html next to the file containing the view. > The whole static stuff seems very hacky for me, examples: > 1) from the same page: [1] "The special name *subpath above is used by > the pyramid.view.static view callable to signify the path of the file > relative to the directory you’re serving." > 2) The special purpose of the "name" attribute of the static view. > 3) The double meaning of add_static_view depending on the first > parameter (i.e. in the external host case) > > I wish this would be cleaned up some day, more consistent and more > intuitive to understand. Yes. It has grown over time. Suggestions welcome. - C -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-de...@googlegroups.com. To unsubscribe from this group, send email to pylons-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-devel?hl=en.