{"id":99,"date":"2008-09-02T00:07:16","date_gmt":"2008-09-01T15:07:16","guid":{"rendered":"http:\/\/www.typea.info\/blog\/index.php\/2008\/09\/02\/google_app_engine_11\/"},"modified":"2008-09-02T00:07:16","modified_gmt":"2008-09-01T15:07:16","slug":"google_app_engine_11","status":"publish","type":"post","link":"https:\/\/www.typea.info\/blog\/index.php\/2008\/09\/02\/google_app_engine_11\/","title":{"rendered":"Google App Engine \u30e6\u30fc\u30b6\u30fc\u30b5\u30fc\u30d3\u30b9 \u91ce\u671b(1.1)"},"content":{"rendered":"<p><a title=\"http:\/\/code.google.com\/intl\/ja\/appengine\/docs\/gettingstarted\/usingusers.html\" href=\"http:\/\/code.google.com\/intl\/ja\/appengine\/docs\/gettingstarted\/usingusers.html\">http:\/\/code.google.com\/intl\/ja\/appengine\/docs\/gettingstarted\/usingusers.html<\/a><\/p>\n<p>Google\u306e\u30e6\u30fc\u30b6\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u5229\u7528\u3067\u304d\u308b\u307f\u305f\u3044\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/GoogleAppEngine1.1_14D42\/userservice01.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"userservice01\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/GoogleAppEngine1.1_14D42\/userservice01_thumb.jpg\" width=\"151\" height=\"107\" \/><\/a>&#160;<\/p>\n<pre class=\"prettyprint linenums\">import wsgiref.handlers\r\n\r\nfrom google.appengine.api import users\r\nfrom google.appengine.ext import webapp\r\n\r\nclass MainPage(webapp.RequestHandler):\r\n    def get(self):\r\n        # \u30e6\u30fc\u30b6\u30fc\u304c\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u3044\u308b\u5834\u5408\u3001\r\n        # \u30e6\u30fc\u30b6\u30fc\u306e User \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u8fd4\u3059\r\n        user = users.get_current_user()\r\n        if user:\r\n            self.response.headers['Content-Type'] = 'text\/plain'\r\n            self.response.out.write('Hello,' + user.nickname())\r\n        else:\r\n            # \u30e6\u30fc\u30b6\u30fc\u304c\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u3044\u306a\u3044\u5834\u5408\u3001\u30e6\u30fc\u30b6\u30fc\u306e\u30d6\u30e9\u30a6\u30b6\u3092\r\n            # Google \u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u30ed\u30b0\u30a4\u30f3 \u30da\u30fc\u30b8\u306b\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3059\u308b\u3088\u3046\u306b\u6307\u793a\r\n            # \u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u306b\u306f\u3001\u3053\u306e\u30da\u30fc\u30b8\u3078\u306e URL (self.request.uri) \u304c\r\n            # \u542b\u307e\u308c\u3066\u3044\u308b\u305f\u3081\u3001\u30e6\u30fc\u30b6\u30fc\u306f Google \u30a2\u30ab\u30a6\u30f3\u30c8 \u30ed\u30b0\u30a4\u30f3\r\n            # \u30b7\u30b9\u30c6\u30e0\u306b\u3088\u308a\u3001\u30ed\u30b0\u30a4\u30f3\u307e\u305f\u306f\u65b0\u898f\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u4f5c\u6210\u5f8c\u3001\r\n\r\n            #\u3053\u306e\u30da\u30fc\u30b8\u3078\u623b\u3055\u308c\u308b\r\n            self.redirect(users.create_login_url(self.request.uri))\r\n\r\ndef main():\r\n    application = webapp.WSGIApplication(\r\n                                         [('\/', MainPage)],\r\n                                         debug=True)\r\n    wsgiref.handlers.CGIHandler().run(application)\r\n\r\nif __name__ == &quot;__main__&quot;:\r\n    main()<\/pre>\n<p>\u5b9f\u884c\u3059\u308b\u3068\u3001\u30c0\u30df\u30fc\u306e\u30ed\u30b0\u30a4\u30f3\u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u305f\u3002 <\/p>\n<p>&#160;<a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/GoogleAppEngine1.1_14D42\/userservice02.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"userservice02\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/GoogleAppEngine1.1_14D42\/userservice02_thumb.jpg\" width=\"182\" height=\"140\" \/><\/a> <\/p>\n<p>\u30ed\u30b0\u30a4\u30f3\u3059\u308b\u3068\u3001\u30e6\u30fc\u30b6\u30fc\u500b\u5225\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u305f\u3002<\/p>\n<p><a href=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/GoogleAppEngine1.1_14D42\/userservice03.jpg\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" border=\"0\" alt=\"userservice03\" src=\"https:\/\/www.typea.info\/blog\/wp-content\/uploads\/image\/GoogleAppEngine1.1_14D42\/userservice03_thumb.jpg\" width=\"186\" height=\"143\" \/><\/a> <\/p>\n<p>\u4eca\u65e5\u306f\u3053\u3053\u307e\u3067\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>http:\/\/code.google.com\/intl\/ja\/appengine\/docs\/gettingstarted\/usingusers.html Google\u306e\u30e6\u30fc\u30b6\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u5229\u7528\u3067\u304d\u308b\u307f\u305f\u3044\u3002 &#160;  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","footnotes":""},"categories":[16,19,20],"tags":[],"class_list":["post-99","post","type-post","status-publish","format-standard","hentry","category-eclipse","category-googleappengine","category-python"],"veu_head_title_object":{"title":"","add_site_title":""},"_links":{"self":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/99","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=99"}],"version-history":[{"count":0,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/posts\/99\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=99"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=99"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.typea.info\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=99"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}