Google app engine

495 views
407 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
495
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Google app engine

  1. 1. Google App engine Senthilkumar M Copyright@share2create License 1
  2. 2. What is Google App Engine? • Google App Engine is a complete development stack that uses familiar technologies to build and host applications on the same infrastructure used at Google. Copyright@share2create License 2
  3. 3. Four runtime environments PHP Python Java GO Copyright@share2create License 3
  4. 4. Your code runs in a sandbox • Secure environment that provides limited access to the underlying operating system. • The sandbox allows App Engine to • distribute web requests across multiple servers • start and stop servers to meet traffic demands • isolate apps in a secure, reliable environment • abstract hardware, operating system and physical location of the web server Copyright@share2create License 4
  5. 5. Sandbox limitations • outbound connections: only through the provided URL fetch and email services or the experimental Socket API. • inbound connections: only HTTP(s) on ports 80/443. • File system access: writing files is not allowed. An application can read only files uploaded with the application code. • no native code: libraries that depend on native code are generally not available. • time limits: app code must terminate within given time limits. (60s for web requests, 10m for tasks but unlimited time for backend jobs) Copyright@share2create License 5
  6. 6. Storing data • Three options for data storage App Engine Data store NoSQL schemeless data storage built in GAE Google Cloud SQL relational SQL database service based on MySQL Copyright@share2create License Google Cloud Storage file based storage 6
  7. 7. What special in host on GAE • No fixed cost pay only on what you use • FREE!!!! • Your APP running on the platform which powers Google service. • App can be scalable to any extend. Copyright@share2create License 7
  8. 8. Lets Run your First App • Download the SDK • Go to https://developers.google.com/appengine/ downloads and grab the Python installer. • Download Python 2.7 installer. • Go to http://www.python.org/download/releases/2.7/ Copyright@share2create License 8
  9. 9. Startup the Launcher Copyright@share2create License 9
  10. 10. Create a Sample Application Copyright@share2create License 10
  11. 11. Lets write your first code • App.yaml => It is configuration file for your application Copyright@share2create License 11
  12. 12. Main.py #!/usr/bin/env python import webapp2 class MainHandler(webapp2.RequestHandler): def get(self): self.response.write('Hello world!') app = webapp2.WSGIApplication([ ('/', MainHandler)], debug=True) Copyright@share2create License 12
  13. 13. Datastore(s) • There are two implementations of datastore • The original one is implemented in google.appengine.ext.db • The new one is called NDB and it is implemented in google.appengine.ext.ndb • They are very similar but not identical • We will cover NDB Copyright@share2create License 13
  14. 14. Creating Data store Entity from google.appengine.ext import ndb class Contact(ndb.Model): name = ndb.StringProperty() email = ndb.StringProperty() birth_date = ndb.DateProperty() Copyright@share2create License 14
  15. 15. Querying the Data store from google.appengine.ext import ndb def StoresByCity(city, limit): query = Store.query(Store.city == city).order(Store.name) return query.fetch(limit, projection=[Store.name, Store.address]) • • • • The Data store API is Object Oriented. Queries are objects Filters and projections are specified by calling methods Make sure you know the limits! Copyright@share2create License 15
  16. 16. Querying the Data store with GQL from google.appengine.ext import ndb def query_info(): qry = ndb.gql("SELECT * FROM Account WHERE balance < :1", 100) return qry • You can write queries with GQL, a SQL-like language. • GQL is translated to NDB's native query API. (This is the opposite of what traditional ORM libraries do!) Copyright@share2create License 16
  17. 17. View templates <html> <body> {% for contact in contacts %} {% if contact.name %} <b>{{ contact.name }}</b> {% else %} Unnamed contact {% endif %} <{{ contact.email }}> {% endfor %} <a href="{{ url }}">{{ url_linktext }}</a> </body> </html> If you use webapp2, Django Templates are supported by default. Copyright@share2create License 17
  18. 18. Dispatch to view templates Here is how to render a template in with webapp2 def render_template(self, view_filename, params=None) if not params: params = {} path = os.path.join(os.path.dirname(__file__), 'views', view_filename) self.response.out.write(template.render(path, params)): Copyright@share2create License 18
  19. 19. Memcache • Memcache is a high-performance, distributed memory object caching system. • Can be used to minimize hits to the Datastore or to save transient state information. from google.appengine.api import memcache def get_data(): data = memcache.get('key') if data is not None: return data else: data = self.query_for_data() memcache.add('key', data, 60) return data Copyright@share2create License 19
  20. 20. My sample host apps • • • • Check out this links http://senonscreen.appspot.com/ http://me2mentor.appspot.com/ http://sentengo.appspot.com/ Copyright@share2create License 20
  21. 21. Questions? Copyright@share2create License 21
  22. 22. Copyright@share2create License 22

×