Last active
November 27, 2017 15:43
-
-
Save cwlau/02e511cb3f23a2dc9c44 to your computer and use it in GitHub Desktop.
Geolocation demo for Google App Engine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# demo from blog.cwlau.com | |
import os | |
os.environ.get('HTTP_X_APPENGINE_CITY', 'unknown city') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# demo from blog.cwlau.com | |
import os | |
os.environ.get('HTTP_X_APPENGINE_COUNTRY', 'unknown country') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# demo from blog.cwlau.com | |
import webapp2 | |
import os | |
class Demo(webapp2.RequestHandler): | |
def get(self): | |
self.response.headers['Content-Type'] = 'text/html' | |
self.response.write('<html>') | |
self.response.write('<title>Geolocation Demo on Google App Engine</title>') | |
self.response.write('<body>') | |
self.response.write('Current City: ' + os.environ.get('HTTP_X_APPENGINE_CITY', 'Unknown City')) | |
self.response.write('<br/>') | |
self.response.write('Current Country: ' + os.environ.get('HTTP_X_APPENGINE_COUNTRY', 'Unknown Country')) | |
self.response.write('</body>') | |
self.response.write('</html>') | |
app = webapp2.WSGIApplication([ | |
('/geolocation', Demo), | |
], debug=True) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment