Displaying Image in cherrypy...problems continue..sorry :-(

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Displaying Image in cherrypy...problems continue..sorry :-(

salvatore.didio

Hello,

I am still having problems displaying  images :-(
I have created a static directory inside the tutorial dir where i've
put the image


[global]
server.socket_port = 8080
server.thread_pool = 10

[/]
tools.staticdir.root="/usr/local/CherryPy-3.0.0beta2/cherrypy/tutorial"

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

-----------------------------------------------------------


import cherrypy

class HelloWorld:
    def index(self):
        return "<img src='/cplogo.jpg' />"

    index.exposed = True

if __name__ == '__main__':
    import os.path
    tutconf = os.path.join(os.path.dirname(__file__), 'tutorial.conf')
    cherrypy.config.update(tutconf)
    cherrypy.quickstart(HelloWorld())


Thanks for your help


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Displaying Image in cherrypy...problems continue..sorry :-(

Tim Roberts

salvatore wrote:

>Hello,
>
>I am still having problems displaying  images :-(
>I have created a static directory inside the tutorial dir where i've
>put the image
>
>
>[global]
>server.socket_port = 8080
>server.thread_pool = 10
>
>[/]
>tools.staticdir.root="/usr/local/CherryPy-3.0.0beta2/cherrypy/tutorial"
>
>[/static]
>tools.staticdir.on = True
>tools.staticdir.dir = "static"
>
>-----------------------------------------------------------
>
>
>import cherrypy
>
>class HelloWorld:
>    def index(self):
>        return "<img src='/cplogo.jpg' />"
>  
>

Since your static directory is called "/static", surely you meant to type:
        return "<img src='/static/cplogo.jpg' />"

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Displaying Image in cherrypy...problems continue..sorry :-(

salvatore.didio

Thanks for tour response Tim, but i have tried it without success:-(


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Displaying Image in cherrypy...problems continue..sorry :-(

salvatore.didio
In reply to this post by Tim Roberts

Thanks for tour response Tim, but i have tried it without success:-(


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Displaying Image in cherrypy...problems continue..sorry :-(

Frank Zheng
In reply to this post by salvatore.didio

hi, today, I still met this problem.
however, I found the answer, use following conf

[global]
server.socketPort = 8080
server.threadPool = 30
server.environment = "production"
static_filter.root = "/home/frank/myweb"

[/css]
static_filter.on = True
static_filter.dir = "css"

[/js]
static_filter.on = True
static_filter.dir = "js"

so, I can use "css/style.css" and "js/my.js" in page now.

you can found this at:
http://docs.cherrypy.org/serving-static-content

I just answer another question about this at python.cn, I think
cherrypy should update the document.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Displaying Image in cherrypy...problems continue..sorry :-(

salvatore.didio

Than's Frank :-)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Displaying Image in cherrypy...problems continue..sorry :-(

Frank Zheng

hi, salvatore:
I made a mistake that my answer only can work with cp2, cp3 need use
your ways, however, you ways can't work, I failed either.
anyone can help us?

Thanks


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Displaying Image in cherrypy...problems continue..sorry :-(

salvatore.didio

I'am glad to see i am not alone in the dark :-)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Displaying Image in cherrypy...problems continue..sorry :-(

Sylvain Hellegouarch

salvatore wrote:
> I'am glad to see i am not alone in the dark :-)
>

Would you mind pasting the error you get or what happens. Also paste
your code and directory layout.

Thanks,
- Sylvain

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Displaying Image in cherrypy...problems continue..sorry :-(

Robert Brewer
In reply to this post by salvatore.didio

salvatore wrote:
>     import os.path
>     tutconf = os.path.join(os.path.dirname(__file__), 'tutorial.conf')
>     cherrypy.config.update(tutconf)
>     cherrypy.quickstart(HelloWorld())

If you're still having problems with static content, you can try having
a look at the new, improved StaticContent wiki page:
http://www.cherrypy.org/wiki/StaticContent

But I think your problem is actually with config file loading. CherryPy
3 has separated application config from global (server) config. So you
need to pass your tutorial.conf file to quickstart:

cherrypy.quickstart(HelloWorld(), config=tutconf)

As I noted in another thread*, I think quickstart should call
cherrypy.config.update (the global conf update) for you, but it doesn't
yet.


Robert Brewer
System Architect
Amor Ministries
[hidden email]

*
http://groups.google.com/group/cherrypy-users/browse_thread/thread/e1e7d4088dcddeac#msg_52625a4469a8c819


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Displaying Image in cherrypy...problems continue..sorry :-(

salvatore.didio
In reply to this post by Sylvain Hellegouarch

Merci Sylvain :-),  I'm going to try Fumanchus's solution


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Displaying Image in cherrypy...problems continue..sorry :-(

salvatore.didio
In reply to this post by Robert Brewer

Thank ou very much, I will tru your solution


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---