GOogle app

 engine 


WHY gae?

PaaS by Google
Run applications by Google Infrastructure
Easy to Build
Easy to Maintain
Easy to Scale
GAE includes some frameworks

Download the GAE SDK for Python 
https://developers.google.com/appengine/downloads


create your app

https://appengine.google.com/





configuration file

app.yaml
application: projectid
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /.*
  script: helloworld.application 




Hello world with webapp2


import webapp2

class MainPage(webapp2.RequestHandler):

    def get(self):
        self.response.write('Hello, World!')


application = webapp2.WSGIApplication([
    ('/', MainPage),
], debug=True) 

http://webapp-improved.appspot.com/

  

COMmANDS

Development environment:
dev_appserver.py --port=9999 myapp
https://developers.google.com/appengine/docs/python/tools/devserver

Upload your app:
appcfg.py update myapp
https://developers.google.com/appengine/docs/python/tools/uploadinganapp



                                                                                                               
                                                                                                             

Windows and mac launcher!


demo users from api

from google.appengine.api import users
import webapp2
class MainPage(webapp2.RequestHandler):

    def get(self):
        user = users.get_current_user()

        if user:
            self.response.headers['Content-Type'] = 'text/plain'
            self.response.write('Hello, ' + user.nickname())
        else:
            self.redirect(users.create_login_url(self.request.uri))

application = webapp2.WSGIApplication([
    ('/', MainPage),
], debug=True) 
https://developers.google.com/appengine/docs/python/users/



DEMO 

HANDLING FORMS








DEMO 

DATA STORE








demo templates 

and static files






making django app

It's one of the most popular frameworks
And it's supported by GAE

Skeleton Project 
https://github.com/TheBlasfem/django-GAE/

Full documentation
https://developers.google.com/appengine/docs/python/cloud-sql/django



modify app.yaml



CloudSQL

Google Cloud SQL is a MySQL database that lives in Google's cloud
Easy to use, doesn't require any software installation or maintenance

Create the instance of CloudSQL in https://console.developers.google.com/

You can use Mysql Clients
mysql -h IPAddress -uroot -p
create database namedb;


config the database in settings.py

DATABASES = {
        'default': {
            'ENGINE': 'google.appengine.ext.django.backends.rdbms',
            'INSTANCE': 'your-app-id:your-instance',
            'NAME': 'namedb',
            'USER': 'root',
        }
    } 

Ensure that the django and google packages would be found when running manage.py
export PYTHONPATH="$PYTHONPATH:/home/user/google_appengine:
/home/user/google_appengine/lib/django_1_5" 

easy way? django-developer

pip install django-developer
http://appsembler.com/blog/deploy-django-apps-to-google-app-engine-with-django-deployer-in-5-minutes/



https://developers.google.com/products/

http://www.meetup.com/gdgopenlima/
https://github.com/TheBlasfem/getting-started-GAE-Python

THANKS





Google App Engine con Python

By Julio López Montalvo

Google App Engine con Python

  • 3,883