List Info

Thread: Images Directory




Images Directory
user name
2007-12-19 04:42:20
Hello,

I have the following small cherrypy application:

import cherrypy

class HelloWorld:

    cherrypy.expose
    def index(self):
        return '''<b>Hello world! --> Really
cool!</b>
                  <img
src="dirback.jpg">'''

    cherrypy.expose
    def myTest(self):
        return "Mytest!"

    myTest.exposed = True


cherrypy.quickstart(HelloWorld())

Where on my local file system do I put the image
(dirback.jpg) ?
Also, where do I put other static files on the file system
like PDF-
files?

Thanks for your answers,
-Thomas

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---


Re: Images Directory
user name
2007-12-19 08:10:02
Hello,
look here - http://www
.cherrypy.org/wiki/StaticContent
You must define folder with static content in configuration
file.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---


Re: Images Directory
user name
2007-12-20 09:26:30
Hello,

Thanks for the link.

I added the following config file, but still it does not
work:

[global]
server.socket_host = "localhost"
server.socket_port = 8090
server.thread_pool = 10

[/]
tools.staticdir.root = "HelloWorld"

[/static]
tools.staticdir.on = True
tools.staticdir.dir = "static"

It cannot find the static image file. Where on the hard disk
should it
be located with my setup?
I have added a HelloWorld/static folder with my image file
under the
cherrypy installation directory.
Still it does not work.

Thanks,
-Thomas

On 19 dic, 15:10, "Martin Stiborský"
<martin.stibor...gmail.com>
wrote:
> Hello,
> look here -http://www
.cherrypy.org/wiki/StaticContent
> You must define folder with static content in
configuration file.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---


Re: Images Directory
user name
2007-12-20 09:41:25
In tools.staticdir.root must be full address to root of your
application.

Example from my configuration file:

[/]
tools.staticdir.root =
"/home/stibi/Python/MyCPweb/"

[/myDefinedFolder]
tools.staticdir.on = True
# this is "real" folder from folder that is
defined in tools.staticdir.root
tools.staticdir.dir = "design/"

If i will insert image, i wrote this:

<img src="/myDefinedFolder/picture.png" />

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---


Re: Images Directory
user name
2007-12-20 09:42:42
On 12/20/07, tderflingergooglemail.com
<tderflingergooglemail.com> wrote:
> I added the following config file, but still it does
not work:
>
> [global]
> server.socket_host = "localhost"
> server.socket_port = 8090
> server.thread_pool = 10
>
> [/]
> tools.staticdir.root = "HelloWorld"
>
> [/static]
> tools.staticdir.on = True
> tools.staticdir.dir = "static"
>
> It cannot find the static image file. Where on the hard
disk should it
> be located with my setup?
> I have added a HelloWorld/static folder with my image
file under the
> cherrypy installation directory.
> Still it does not work.

The path to your static resources has to be an absolute
path.  This is done by:
1) Providing an absolute path to tools.staticdir.dir.
2) Providing an absolute path to tools.staticdir.root and
paths
relative to that one for each tools.staticdir.dir entry.

In your case, do something like:

tools.staticdir.root = '/full/path/to/HelloWorld'

You should not have to put any files in the CherryPy
installation
directory.  In fact, I would discourage that 

Christian
http://www.dowski.com

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---


Re: Images Directory
user name
2007-12-20 09:49:54
tderflingergooglemail.com schrieb:
> tools.staticdir.root = "HelloWorld"

Hello thomas!

Try it with an absolute path.

``tools.staticdir.root = "<absolute
path>"``


Regards,
Gerold


-- 
____________________________________________________________
____________
Gerold Penz - bcom - Programmierung
     http://halvar.at | http://sw3.at | http://bcom.at
Wissen hat eine wunderbare Eigenschaft:
     Es verdoppelt sich, wenn man es teilt.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---


Re: Images Directory
user name
2007-12-20 10:31:39
I have the same question about static file, and I think
your
explanation is better than that in the StaticContent from
cherrypy
website.

Thanks,

On Dec 20, 10:41 am, "Martin Stiborský"
<martin.stibor...gmail.com>
wrote:
> In tools.staticdir.root must be full address to root of
your application.
>
> Example from my configuration file:
>
> [/]
> tools.staticdir.root =
"/home/stibi/Python/MyCPweb/"
>
> [/myDefinedFolder]
> tools.staticdir.on = True
> # this is "real" folder from folder that is
defined in tools.staticdir.root
> tools.staticdir.dir = "design/"
>
> If i will insert image, i wrote this:
>
> <img src="/myDefinedFolder/picture.png"
/>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---


Re: Images Directory
user name
2007-12-20 10:27:41
Thanks for all your answers.

The absolute path works!

Greets,
-Thomas

On 20 dic, 16:49, Gerold Penz <gerold.p...aon.at> wrote:
> tderflin...googlemail.com schrieb:
>
> > tools.staticdir.root = "HelloWorld"
>
> Hello thomas!
>
> Try it with an absolute path.
>
> ``tools.staticdir.root = "<absolute
path>"``
>
> Regards,
> Gerold
> 
>
> --
>
____________________________________________________________
____________
> Gerold Penz - bcom - Programmierung
>      http://halvar.at|http://sw3.at|http://bcom.at
> Wissen hat eine wunderbare Eigenschaft:
>      Es verdoppelt sich, wenn man es teilt.

--~--~---------~--~----~------------~-------~--~----~
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-8]

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