How to directly handle a POST?

View: New views
2 Messages — Rating Filter:   Alert me  

How to directly handle a POST?

by Mattdidit :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hey guys -

I'd like to manually handle a POST like I can in an HTTPBaseServer
subclass (which I can't use b/c it is single-threaded).  This should
be easy but I'm not really comprehending the whole hooks system.  Is
there a simple way to do the equivalent of the following?  Thanks -

        def do_POST(self):
                #<<< double-check this
                self.query_string = self.rfile.read( int(self.headers
['Content-Length']))
                self.args = dict(cgi.parse_qsl(self.query_string))
                msg = self.args['body']

                f = open('log.txt','a')
                f.write(msg + '\n')
                f.close()

                self.send_response(200)
                self.send_header('Content-type', 'text/plain')
                self.send_header('Content-length', len(msg) )
                self.end_headers()

                self.wfile.write(msg)

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


Re: How to directly handle a POST?

by Christian Wyglendowski-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Tue, Sep 15, 2009 at 11:49 PM, Mattdidit <mattyoungrev3@...> wrote:
>
> Hey guys -
>
> I'd like to manually handle a POST like I can in an HTTPBaseServer
> subclass (which I can't use b/c it is single-threaded).

Hi.  This link should show you how to do exactly what you want.

http://www.cherrypy.org/wiki/PageHandlers#MethodDispatcher

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-users@...
To unsubscribe from this group, send email to cherrypy-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---