everyone : ) I have A database that can search like "
http://key.xxxxxx.org:10093/?q=" when type the keyword in url (behind the
=mark), it can show lots of json data.
Now i write a simple webapp on GAE use webapp2 : on the /search page, when
i type the keyword, it can parse the jsondata content on the /result page.
Here is my part of code :
def renderJson():
conn = httplib.HTTPConnection('key.eagle-project.org:10093')
conn.request('GET', '/%E7%A0%B4%E7%A2%8E%E6%9C%BA')
res = conn.getresponse()
data = res.read()
j = json.loads(data)
return j['data']['group'][0]['resultitem'][0]['word']
class BaseHandler(webapp2.RequestHandler):
def render(self, template, **kw):
self.response.out.write(render_str(template, **kw))
def write(self, *a, **kw):
self.response.out.write(*a, **kw)
class Result(BaseHandler):
def get(self):
#q = self.request.get
self.render('result.html', result = renderJson())
app = webapp2.WSGIApplication([
('/search', Search),
('/result', Result)
],
debug=True)
How can i parse the params in url and render the content out the result
page, the templates that i parse the {{result}},and how parse the search
'q' into the conn.quest ?
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.