Okay, it works. Thank-you!
Btw, my home page is just a few lines with a simple graphic (of 3kb
size) but it takes an age to display. Any ideas?
Dinesh
On Feb 22, 11:05 pm, Tzury Bar Yochay <[EMAIL PROTECTED]> wrote:
> use '/static/....' instead of 'static/...'
>
> see the webpy sourcecode:
> httpserver.py: if self.path.startswith('/static/'):
> httpserver.py: if path.startswith('/static/'):
>
> On Feb 23, 6:50 am, dineshv <[EMAIL PROTECTED]>
> wrote:
>
> > You know, this was exactly what I was doing (ie. separate folders for
> > the html, css etc. files) and it didn't work. Just tried again, and
> > it still doesn't work!
>
> > The Python py file is in the same folder as the main html file. The
> > main html file has the proper link to the css file ie. <link
> > type='text/css' rel='stylesheet' href='static/css/mainstyle.css' />
>
> > The " print open('index.html').read() " statement displays the
> > index.html page but NOT as defined by the css.
>
> > Uhmmm!
> > ..................................
>
> > On Feb 22, 3:30 pm, jac <[EMAIL PROTECTED]> wrote:
>
> > > 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
-~----------~----~----~----~------~----~------~--~---