List Info

Thread: Re: External Javascript & CSS




Re: External Javascript & CSS
user name
2007-09-06 15:34:57
W liście MikeC z dnia czwartek, 6 września 2007 22:22:
> I realize this question is pretty basic, but my
knowledge of web
> programming in general and cherrypy specifically is,
well, pretty less
> than basic.
>
> How can I let cherrypy know where my root directory is?
I want to be
> able to specify HTML with stuff like this...
>
> ...
> <script
src="/static/javascript/MochiKit.js"
type="text/javascript">
> </script>
> ...

It has nothing to do with CherryPy - it's not the server
that will try to find 
the javascript file - it's the user's browser. You have
three options - 
either specify the relative path to the file (so if the page
containing 
<script> tag is at /Root/index then you'll have to
specify 
src="../static/javascript/MochiKit.js"), specify
the absolute path 
(src="<your_server>/static/javascript/Mochikit.js
") or use <base> tag (google 
for details).

Personally I use <base> tags in most of my
applications.

Both when using absolute paths and when using <base>
tag you'll need to know 
the mounting point of your app and server name - this can be
retrieved from 
cherrypy with cherrypy.url("/")

-- 
Paweł Stradomski

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )