Static directory not working

567 views
Skip to first unread message

Ash Courchene

unread,
Jun 17, 2012, 1:41:28 AM6/17/12
to we...@googlegroups.com
Hello everyone,

I bet this question gets asked like 1000 times a day, but Im having trouble getting the stylesheet to work. I set up a static directory/folder like the web.py cookbook describe, but I CAN NOT figure out why it's not working. I'll show you how I set up the directory, and Im working on the built-in server - I guess? Im still kind of new, but I followed the install instructions, so whatever server that is, Im using it. The address I type in to see it is http://localhost:8080/...
Anyway, here is the directory setup.

/website
  -app.py
  /static
    -styles.css
  /template
    -index.html
    -layout.html


Then in the layout code, I have <link rel="stylesheet" type="text/css" href="static/styles.css" /> in between the <head></head> tags, but nothings working. If someone could point me in the right direction, that'd be great. Thanks

Anand Chitipothu

unread,
Jun 18, 2012, 3:12:29 AM6/18/12
to we...@googlegroups.com
I think you should use "/static/styles.css" instead of "static/styles.css".

Anand

Ash Courchene

unread,
Jun 18, 2012, 10:17:52 PM6/18/12
to we...@googlegroups.com
oh yeah... I did that. It just didn't seem to work no matter what I did.
with the / at the beginning, without the /... I'm not even sure.
Oh well, i'll figure something out. Thanks

Anand Chitipothu

unread,
Jun 18, 2012, 10:19:58 PM6/18/12
to we...@googlegroups.com
On Tue, Jun 19, 2012 at 7:47 AM, Ash Courchene <ash.co...@gmail.com> wrote:
> oh yeah... I did that. It just didn't seem to work no matter what I did.
> with the / at the beginning, without the /... I'm not even sure.
> Oh well, i'll figure something out. Thanks

Do you see a directory listing on http://0.0.0.0:8080/static/ ?

Ash Courchene

unread,
Jun 18, 2012, 10:25:12 PM6/18/12
to we...@googlegroups.com
nope, all I get is a "Not Found" in the corner of the page.
Im not even sure what to do anymore... :(

Ash Courchene

unread,
Jun 18, 2012, 10:26:15 PM6/18/12
to we...@googlegroups.com
Oh. Also, when i add the trailing slash, I get this:

Error response

Error code 404.

Message: File not found.

Error code explanation: 404 = Nothing matches the given URI.

Tomas Schertel

unread,
Jun 19, 2012, 12:22:40 AM6/19/12
to we...@googlegroups.com
Have you changed current directory using os.path maybe?

Ash Courchene

unread,
Jun 19, 2012, 4:03:36 AM6/19/12
to we...@googlegroups.com
Um... not that Im aware of. Is that something I need to do?
If so, pardon my ignorance but how would one do that?

Tomas Schertel

unread,
Jun 19, 2012, 10:06:29 AM6/19/12
to we...@googlegroups.com
I don't think it's the case because static dir is relative to your app.py.
Take a look in rendered source from your browser.
Compare what you wrote with what you get in there.
You should see the same: <link rel="stylesheet" type="text/css" href="/static/styles.css" />

Another thing you should see is your browser's cache. I'm facing some issues with it.
Try turn off browser's cache.

I hope it helps.

Ash Courchene

unread,
Jun 30, 2012, 11:25:11 AM6/30/12
to we...@googlegroups.com
It did help. The cache of all things!
Thank you very much
Reply all
Reply to author
Forward
0 new messages