I tried now many things and I googled for hours but I couldn’t solve my problem.
Config File:
[/]
tools.staticdir.root = "/Users/phil/Dropbox/Projects/AppName"
[/main.css]
tools.staticfile.on = True
tools.staticfile.filename = "/Users/phil/Dropbox/Projects/AppName/css/main.css"
[/images]
tools.staticdir.on = True
tools.staticdir.dir = "images"
CherryPy Code:
import cherrypy, os
class AppName(object):
def index(self):
return "<img src='images/logo.jpeg'>"
index.exposed = True
cherrypy.config.update('/Users/phil/Dropbox/Projects/AppName/conf/AppName.config')
cherrypy.quickstart(AppName())
My problem is that it doesn’t work, I tried everything with combining paths and so on but the image and the css won’t load when I do sth like return ‘”
Here is the error I get when loading my Application:
127.0.0.1 - - [24/May/2012:22:28:47] "GET /images/logo.jpeg HTTP/1.1" 404 1268 "http://localhost:8080/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.46 Safari/536.5"
Not sure what the Problem was, but this works:
Start App with:
CherryPy Code:
I think the / before the images is also important. Thanks to all