introduccion app engine con python
DESCRIPTION
Slides de la charla en GTUG Buenos Aires acerca de el Google App Engine con PythonTRANSCRIPT
![Page 1: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/1.jpg)
Sebastián [email protected]: sserrano44 http://www.lp-gtug.or
g
Google App Engine + Pythonen 5 minutos
![Page 2: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/2.jpg)
Cloud Computing??
![Page 3: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/3.jpg)
0% Administracion = 100% Desarrollo
![Page 4: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/4.jpg)
Google App Engine
• Fácil de Desarrollar
• Fácil de Mantener
• Fácil de Escalar
![Page 5: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/5.jpg)
Servicios del App Engine
![Page 6: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/6.jpg)
Lenguajes
![Page 7: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/7.jpg)
Empezar es GRATIS!• ~5M pageviews/month
• 6.5 CPU hrs/day
• 1 GB storage
• 650K URL Fetch calls/day
• 2,000 recipients emailed
• 1 GB/day bandwidth
• 100,000 tasks enqueued
• 650K XMPP messages/day
![Page 8: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/8.jpg)
App Engine Dashboard
![Page 9: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/9.jpg)
SDK Console
![Page 10: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/10.jpg)
Primeros pasos App Engine
• Descargar el SDKo http://code.google.com/appengine
• Registrar una cuentao https://appengine.google.com
• Escribir código - deploy!
![Page 11: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/11.jpg)
$ dev_appserver.py helloworld # run dev svr$ appcfg.py update helloworld # deploy live
Linux, MacOS, etc. command-line:
Windows GUI (y Mac):
Arrancar un proyecto
![Page 12: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/12.jpg)
app.yaml – archivo configuración main principal
index.yaml – generado automáticamente para indexar nuestros datos
main.py – el código de la aplicación
Contenido basico
![Page 13: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/13.jpg)
main.py
![Page 14: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/14.jpg)
$ dev_appserver.py helloworldINFO 2009-03-04 17:51:22,354 __init__.py]
Local development server
![Page 15: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/15.jpg)
Deploying the application
• Set application identifier• Run deploy script• You're live!
![Page 16: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/16.jpg)
Modifying app.yamlapplication: helloworldversion: 1runtime: pythonapi_version: 1
handlers:- url: .*script: main.py
![Page 17: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/17.jpg)
Running the deploy script
$ appcfg.py update helloworldScanning files on local disk.Initiating update.Email: ...
![Page 18: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/18.jpg)
You're live!
![Page 19: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/19.jpg)
Demo time??
![Page 20: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/20.jpg)
main.py: Skeleton applicationfrom google.appengine.ext import webappfrom google.appengine.ext.webapp import util
class MainHandler(webapp.RequestHandler): def get(self): self.response.out.write('Hello world!')
def main(): application = webapp.WSGIApplication([('/', MainHandler)], debug=True) util.run_wsgi_app(application)
if __name__ == '__main__': main()
![Page 21: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/21.jpg)
main.py: Adding a handlerfrom google.appengine.ext import webappfrom google.appengine.ext.webapp.util import run_wsgi_app
class MainHandler(webapp.RequestHandler): def get(self): self.response.out.write('<h1>Hello world!</h1>') self.response.out.write(''' <form action="/sign" method=post> <input type=text name=content> <br><input type=submit value="Sign Guestbook"> </form> ''')
class GuestBook(webapp.RequestHandler): def post(self): self.response.out.write( '<h2>You wrote:</h2> %s' % self.request.get('content') )
application = webapp.WSGIApplication([ ('/', MainHandler), ('/sign', GuestBook),], debug=True)
# start_wsgi_app etc ...
![Page 22: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/22.jpg)
main.py: Persisting to the datastoreclass GuestBook(webapp.RequestHandler): def post(self): greeting = Greeting() greeting.content = self.request.get('content') greeting.put() self.redirect('/')
![Page 23: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/23.jpg)
main.py: Collecting values from the datastoreclass MainHandler(webapp.RequestHandler): def get(self): self.response.out.write('Hello world!') self.response.out.write('<h1>My GuestBook</h1><ol>') greetings = Greeting.all() for greeting in greetings: self.response.out.write('<li> %s' % greeting.content) self.response.out.write(''' </ol><hr> <form action="/sign" method=post> <textarea name=content rows=3 cols=60></textarea> <br><input type=submit value="Sign Guestbook"> </form> ''')
![Page 24: Introduccion app engine con python](https://reader030.vdocuments.pub/reader030/viewer/2022012916/554be740b4c9055a368b4aa6/html5/thumbnails/24.jpg)
Live demo??