Forums

webpy serving static files(css/image)

Hi, I have a problem in which I can't load the css file. Not found(404) My css file can be found in my /home/marzim83/main/webpy/static/main.css directory.

$def with (page)
<html>
<head>
<title>Base</title>
<link rel="stylesheet" type="text/css" href="/home/marzim83/main/webpy/static/main.css" media="screen" />
</head>
<body>

Also, tried putting the /static/main.css in var/www/ and use the href="static/main.css" but to no avail.

Thanks.

Hi there -- I took a look at your site to see if there was anything odd there, but it's showing an error at the moment -- looks like there's an import error somewhere from the logs.

Yes. I tried to made some changes(revert back my changes to working one) and try to reload it but I haven't seen an update on the log and still "something went wrong" page I got.

Odd. I'm investigating.

OK, sorry about that. The web server your app was running on had a problem, so I've rebooted it. Your site looks like it's working now.

Regarding the static file problem I should have realised the problem from looking at your code listing above. You're specifying the path (in the href) as /home/marzim83/main/webpy/static/main.css. We don't expose all of your files to people who can see your web app (for obvious security reasons). You need to set up explicit mappings from URLs for directories to real directories in your file space to say what other people can access, in the "static files" table on the "Web" tab.

So I would recommend you add a static file mapping from the URL /static to the directory /home/marzim83/main/webpy/static/, then use just /static/main.css in your template. That should work fine.

Yeah it works. Thanks man. But back to my main problem, when I access my main.css file, all the styles weren't loaded. I reverted my code to use the css file and see that no styles been applied.

Thanks.

EDIT: haven't read your latest reply...I'll try that one. Thanks.

Cool, let us know how it goes :-)

Works like a charm. Thanks a lot man!

No problem, thanks for confirming!