[CherryPy]Serve dynamic binary file in cherrypy?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mep

    #1

    [CherryPy]Serve dynamic binary file in cherrypy?

    Hi,
    After lookup in cherrypy site and google for a while, I haven't
    found any information about cherrypy how to serve dynamic binary
    file(some generated charts).Is there any easy way to do this?
    In cherrypy 2.0 & python 2.4

    --
    Best Regards,
    Wang Kebo




  • mep

    #2
    Re: [CherryPy]Serve dynamic binary file in cherrypy?

    Resolved. Simplely specifiy content mime type before return.


    --
    Best Regards,
    Wang Kebo




    "mep" <mep_@163.com > wrote in message news:397vt5F5qq vrkU1@individua l.net...[color=blue]
    > Hi,
    > After lookup in cherrypy site and google for a while, I haven't
    > found any information about cherrypy how to serve dynamic binary
    > file(some generated charts).Is there any easy way to do this?
    > In cherrypy 2.0 & python 2.4
    >
    > --
    > Best Regards,
    > Wang Kebo
    >
    > http://www.huihoo.org/~mep
    >
    >[/color]


    Comment

    • Remi Delon

      #3
      Re: [CherryPy]Serve dynamic binary file in cherrypy?

      "mep" <mep_@163.com > wrote in message news:<397vt5F5q qvrkU1@individu al.net>...[color=blue]
      > Hi,
      > After lookup in cherrypy site and google for a while, I haven't
      > found any information about cherrypy how to serve dynamic binary
      > file(some generated charts).Is there any easy way to do this?
      > In cherrypy 2.0 & python 2.4[/color]

      Yes, there is an easy way: have your handler method return the binary
      data, and set the Content-Type before returning the data, like this:

      # class Root:
      # def index(self):
      # ... Generate binary data in "data" ...
      # cpg.response.he aderMap['Content-Type'] = 'image/gif'
      # return data

      Remi.

      Comment

      Working...