2009年11月21日土曜日

Google App Engine(python)でUserAgentを取得する方法

参考ページ

webobのRequestオブジェクトに関して調べた。

サンプルコード
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

class Receiver(webapp.RequestHandler):
  def get(self):
    self.response.out.write(
    """
    <html>
      <body>
        <b>%s</b>
      </body>
    </html>
    """ % self.request.user_agent)
    
    
application = webapp.WSGIApplication([
  ("/", Receiver)
], debug=True)

def main():
  run_wsgi_app(application)

if __name__ == "__main__":
  main()

http://localhost:8080/にアクセスすると表示される

0 件のコメント:

コメントを投稿