Problems with static file handler

3 views
Skip to first unread message

Voltron

unread,
May 11, 2009, 2:57:17 PM5/11/09
to juno-framework
Given this init dict:

init(
{'use_templates': True,
'template_lib' : 'mako',
'template_root': './templates/',
'use_static' : True,
'static_url': '/static/*:file/',
'static_root': './static/',
'static_handler': static_serve,
}

And in my template:

<link rel="stylesheet" href="/static/css/grid.css" type="text/css"
media="screen, projection" />
<link rel="stylesheet" href="/static/css/reset.css" type="text/css"
media="screen, projection" />
...
...
None of my static files where found, all ended in 404s, I tried
several combinations, my file structure is as follows

myapp/
/templates/
/static/css/grid..css <-- static files live in here
/static/css/reset..css <-- static files live in here
myapp.py


Any ideas what I am doing wrong?

Thanks




Brian

unread,
May 12, 2009, 4:31:01 AM5/12/09
to juno-framework
Are you using mod_wsgi or something similar for serving? With
mod_wsgi, the './static/' is relative to its working directory (which
is probably not where your app is). You either have to specify the
full path from '/', or not set anything for template_root and
static_root and let Juno figure out the full path (to do this, just
leave template_root and static_root out of your init dict - note that
this only works if your static/ folder and templates/ folder are in
the same directory as your app, but it looks like you have it set up
that way so you should be fine.).

Let me know if you're using the dev server and getting these 404s,
offhand I can't think of why that would happen.

-- Brian

Voltron

unread,
May 12, 2009, 6:11:12 AM5/12/09
to juno-framework
Hi Brian!

I am using Werzegs test server, Does this mean that the test servers
do not serve static files and only works when one uses mod_wsgi or
FCGI with a real web server.

Voltron

unread,
May 14, 2009, 12:51:29 PM5/14/09
to juno-framework
Ping!


Any ideas? I am blocking on this


Thanks

Brian

unread,
May 15, 2009, 1:45:56 AM5/15/09
to juno-framework
Every server should serve static files (the only issue being that with
a mod_* server you can't use the './' notation), so that shouldn't be
the problem. I can't seem to replicate this issue with either Juno's
builtin server or with Werkzeug's server given the init dict you
posted. Only ideas: 1) Are you redefining static_serve (is that why
its in your dict?)? If so, could be a problem in your new version. 2)
This was a little unclear due to the formatting, but is your python
script in the same directory that your static directory is in (i.e.,
if you do 'ls myapp/', you should see app.py and static/ in your
results)? 3) Maybe try leaving out static and template roots and let
Juno fill in the full paths, as those locations are the defaults -
perhaps Werkzeug's server is having problems finding your files.

Brian
Reply all
Reply to author
Forward
0 new messages