Hi,

I am new to web programming ( certainly to GAE ). I need have an
arrangement where I can update data from my custom C code and display
it on web. I found that HTTP POST is a good candidate to upload
"light" data.

I am trying to understand the GAE and web programming simultaneously
and have modified code available on net to try out the possibilities
for the same.

Here is the code for GAE.

<import package here>

class GetPage(webapp.RequestHandler):
    def get(self):
        self.response.out.write("""
          <html>
            <body>
                <p> In Get </p>
            </body>
          </html>""")

class PostPage(webapp.RequestHandler):
    def post(self):
        self.response.out.write('<html><body>In Post<pre>')
 
self.response.out.write(cgi.escape(self.request.get('content')))
        self.response.out.write('</pre></body></html>')

application = webapp.WSGIApplication( [('/', GetPage),  ('/post',
PostPage)], debug=True)

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()


The client code (written in python for experimentation now, planning
to use libcurl for C later) which can send a Http POST request is here
-

h = httplib2.Http()
form_fields = {
  "content" : "Yippy!! POST works"
}
data = urllib.urlencode(form_fields)

resp, content = h.request('http://107.108.58.183:8080',  'POST',
data)


When I host the GAE code, I am able to process GET request ( able to
see the GetPage output ).
However, when I send a POST request via client, I see no output in
browser( which is obvious since browser did not send the POST
request). However, I see the local GAE server prints message
indicating it has received the POST request).

The question is- how can I display the data ( string "Yippy!! POST
works" here) on the web page when asked for from a browser?

I am newbie in the field and will highly appreciate any help.

Thanks,
Ankur

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

Reply via email to