forked from GoogleCloudPlatform/appengine-guestbook-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelloworld.py
More file actions
27 lines (20 loc) · 694 Bytes
/
Copy pathhelloworld.py
File metadata and controls
27 lines (20 loc) · 694 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from google.appengine.api import users
import webapp2
class MainPage(webapp2.RequestHandler):
def get(self):
# [START get_current_user]
# Checks for active Google account session
user = users.get_current_user()
# [END get_current_user]
# [START if_user]
if user:
self.response.headers['Content-Type'] = 'text/html; charset=utf-8'
self.response.write('Hello, ' + user.nickname())
# [END if_user]
# [START if_not_user]
else:
self.redirect(users.create_login_url(self.request.uri))
# [END if_not_user]
app = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)