If you are actually using the template system in webpy then you would
put the main html file somewhere outside of the static directory, then
render it. The link element in the html would then point to the css
from the same directory as the main python file (important!). Like
jsp's if you are rendering or even just statically opening and reading
an html page, all of the urls and hrefs within the html page would be
as if the html page is actually at the server root.

From my actual experience though I've developed an aversion for
templating systems(psp, cheetah, jsp, etc.). I just enjoy separating
my languages. Anyway, my normal structure is:

server.py
otherpythonfiles.py
index.html
otherhtmlfiles.html
static/
        js/
                 javascriptfile.js
        css/
                mainstyle.css
                iespecific.css

now in the python I would have:

class index:
    def GET(self):
        print open('index.html').read()

if you want you could set the content-type but this is a quick
example,

the actual html would then contain, the proper link to the css and
javascript files:

<link type='text/css' rel='stylesheet' href='static/mainstyle.css' />
<script type='text/javascript' src='static/js/javascriptfile.js'></
script>

images would be handled by sticking the images in the static folder or
a subfolder of the static folder, and setting the proper url property
and it would work. The css would have to do "background-image: url(../
imgsFolder/image.png)" and it would work.

Wow. That got kind of long, but after writing a couple of applications
and trying a lot of different folder structures and serving methods
out, this has worked out the best for me.
Hope it helps.

On Feb 22, 12:57 pm, dineshv <[EMAIL PROTECTED]>
wrote:
> Apologies for the simple question but was is the best practice in
> webpy to render an html page which uses a css file?  I don't have
> template files (yet). Sample code is below.
>
> Dinesh
> ...................................................................
> staticFolder = 'C:/siteFiles/static/'
> render = web.template.render(staticFolder)
>
> homePage = staticFolder + 'index.html'
> cssFile = staticFolder + 'main.css'
>
> urls = (
>  '/', 'index')
>
> class index:
>     def GET (self):
>         print render.homePage        # ??? what is the best practice
> in webpy to render html file that uses a css file?
>
> web.webapi.internalerror = web.debugerror
> if __name__ == '__main__':
>     web.run(urls, globals(), web.reloader)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to