SlideShare a Scribd company logo
+ Google
Who?

CADEMY

Bruno Rocha
bruno@rocha.com
http://github.com/rochacbruno
http://twitter.com.rochacbruno
http://brunorocha.org
http://pythonhub.com

www.quokkaproject.org
Full Stack
Framework
Faz as escolhas por você e oferece uma
plataforma completa

Micro Framework

Define apenas o básico
(WSGI, request, response, session etc)

(ORM, Templates, Organização de arquivos,
arquivos de configurações, etc)
+ Fácil
- controle

Crescimento gradativo
+ trabalhoso
+ controle
What The Flask?
Flask is a microframework for Python based
on Werkzeug, Jinja 2 and good intentions.
Werkzeug - WSGI library

from werkzeug.serving import run_simple
from werkzeug.wrappers import Request, Response
@Request.application
def application(request):
return Response('Hello World!')
run_simple('localhost', 4000, application)
Jinja - Template engine

{% macro render_user(user) %}
<li><a href="{{ user.url }}">{{ user.username }}</a></li>
{% endmacro %}

{% from _above_file.html import render_user %}
<title>{% block title %}{% endblock %}</title>
<ul>
{% for user in users %}
{{ render_user(user) }}
{% endfor %}
</ul>
Good intentions.

# thread locals
from flask import request, session, g
# extensions
from flask.ext import AmazingExtension
# blueprints
from flask import Blueprint
blog = Blueprint(“blog_blueprint”)
blog.template_folder = “path/to/folder”
blog.static_folder = “path/to/static”
# Application factory
app = create_app(**kwargs)
app.register_blueprint(blog)
AmazingExtension(app)
It is not a framework, it is a pattern!

Good intentions

flask.ext.*
your_app.py
your_app.py
$ pip install flask, flask-security, flask-admin, xpto-orm
from
from
from
from
from

flask import Flask
flask.ext.security import Security
flask.ext.admin import Admin
somewhere.db.models import UserDatastore
somewhere.views import indexpage

def create_app(**config):
app = Flask(“myapp”)
app.config_from_object(config)
Admin(app)
Security(app, UserDatastore)
app.add_url_rule(“/index/<something>”, view_func=indexpage)
return app
if __name__ == “__main__”:
app = create_app(SECRET_KEY=”XYZ”)
app.run()
Blueprints
Um Blueprint funciona de forma similar a um objeto Flask, mas na verdade não
é uma aplicação, mas sim um projeto de como construir ou extender uma
aplicação

from flask import Blueprint, render_template
blog_extension = Blueprint(“my_blog_extension”)
blog_extension.endpoint = “/blog”
blog_extension.template_folder = “path/to/blog_templates”
blog_extension.static_folder = “path/to/blog_static”
@blog_extension.route(“/index”)
def blog():
posts = some_db_or_orm.posts.query()
return render_template(“blog.html”, posts=posts)
blog_blueprint.py
from blog_blueprint import blog_extension

your_app.py

def create_app(**config):
app = Flask(“myapp”)
...
app.register_blueprint(blog_extension)
return app
●

●

Flask subclass
○ class MyOwnFlask(Flask):
pass
application factory
○ app = create_app(**config)
○ evitar import circular

●

Blueprints
○ Mesmo que seja uma one-page-app

●

Flask-Admin
○ Modular, insira qualquer view no admin, crud completo, actions, filters

●

Flask-Security
○ Login, Logout, Lembrar senha, Register, Access control, permissions

●

Flask-script
○ python manage.py faça_me_um_sanduiche

●

app.config_from_envvar
○ Settings desacoplado da app
○ export APP_SETTINGS=”/path/to/settings.cfg”
○ app.config_from_envvar(“APP_SETTINGS”)
and Google ?
http://bit.ly/flask-gae
# app.yaml
application : nome_do_app
version : 1
runtime : python27
api_version : 1
threadsafe: true
libraries:
- name: jinja2
version: "2.6"
- name: markupsafe
version: "0.15"
handlers:
- url: /static
static_dir : your_app_folder/static
- url: .*
script : main.app

# your_app.py
from flask import Flask
def create_app():
app = Flask(__name__)
return app
# main.py
from werkzeug import DebuggedApplication
from your_app import create_app
app = DebuggedApplication(create_app())
https://github.com/sashka/flask-googleauth
# your_app.py
from flask import Flask
from flask.ext.googleauth import GoogleFederated
from .configurator import register_views
def create_app():
app = Flask(__name__)
app.secret_key = “XYZ”
auth = GoogleFederated("dominio.com", app)
register_views(app, auth)
return app

# configurator.py
from .views import myview, …, ...
def register_views(app, auth)
secret = auth.required(myview)
app.add_url_rule(“/secret/”, view_func=secret)
…
...

# views.py
from flask import g
def myview()
return "Logged user, %s (%s)" % (g.user.name, g.user.email)
…
...
github.com/rochacbruno/Flask-GoogleMaps
pip install flask-googlemaps

from flask import Flask
from flask.ext.googlemaps import GoogleMaps
app = Flask(__name__)
GoogleMaps(app)

<div>
{{googlemap("my_awesome_map", 0.23234234, -0.234234234, markers=[(0.12, -0.45345), ...])}}
</div>
Thank you!
Bruno Rocha
http://brunorocha.org
bruno@rocha.com
http://github.com/rochacbruno
http://twitter.com.rochacbruno
http://pythonhub.com

www.quokkaproject.org

More Related Content

What's hot

Python/Flask Presentation
Python/Flask PresentationPython/Flask Presentation
Python/Flask Presentation
Parag Mujumdar
 
Wykorzystanie form request przy implementacji API w Laravelu
Wykorzystanie form request przy implementacji API w LaraveluWykorzystanie form request przy implementacji API w Laravelu
Wykorzystanie form request przy implementacji API w Laravelu
Laravel Poland MeetUp
 
Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)
LumoSpark
 
Laravel Beginners Tutorial 1
Laravel Beginners Tutorial 1Laravel Beginners Tutorial 1
Laravel Beginners Tutorial 1
Vikas Chauhan
 
Intro to Laravel 4
Intro to Laravel 4Intro to Laravel 4
Intro to Laravel 4
Singapore PHP User Group
 
Datagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and BackgridDatagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and Backgrid
eugenio pombi
 
Symfony2 Introduction Presentation
Symfony2 Introduction PresentationSymfony2 Introduction Presentation
Symfony2 Introduction PresentationNerd Tzanetopoulos
 
Alfresco study37 alfresco_ng2_components
Alfresco study37 alfresco_ng2_componentsAlfresco study37 alfresco_ng2_components
Alfresco study37 alfresco_ng2_components
Takeshi Totani
 
Desenvolvendo uma aplicação híbrida para Android e IOs utilizando Ionic, aces...
Desenvolvendo uma aplicação híbrida para Android e IOs utilizando Ionic, aces...Desenvolvendo uma aplicação híbrida para Android e IOs utilizando Ionic, aces...
Desenvolvendo uma aplicação híbrida para Android e IOs utilizando Ionic, aces...
Juliano Martins
 
Getting started with Salesforce DX & CLI
Getting started with Salesforce DX & CLIGetting started with Salesforce DX & CLI
Getting started with Salesforce DX & CLI
Michael Gill
 
Learn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutesLearn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutes
Larry Cai
 
A few good JavaScript development tools
A few good JavaScript development toolsA few good JavaScript development tools
A few good JavaScript development tools
Simon Kim
 
Voiture tech talk
Voiture tech talkVoiture tech talk
Voiture tech talk
Hoppinger
 
Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)
Yuriy Senko
 
Add new commands in appium 2.0
Add new commands in appium 2.0Add new commands in appium 2.0
Add new commands in appium 2.0
Kazuaki Matsuo
 
Laravel for Web Artisans
Laravel for Web ArtisansLaravel for Web Artisans
Laravel for Web Artisans
Raf Kewl
 
Plugin development wpmeetup010
Plugin development wpmeetup010Plugin development wpmeetup010
Plugin development wpmeetup010
Barry Kooij
 
Manage appium dependencies with -appium-home in appium 2.0
Manage appium dependencies with  -appium-home in appium 2.0Manage appium dependencies with  -appium-home in appium 2.0
Manage appium dependencies with -appium-home in appium 2.0
Kazuaki Matsuo
 
Scalable web application architecture
Scalable web application architectureScalable web application architecture
Scalable web application architecture
postrational
 
RESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroRESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher Pecoraro
Christopher Pecoraro
 

What's hot (20)

Python/Flask Presentation
Python/Flask PresentationPython/Flask Presentation
Python/Flask Presentation
 
Wykorzystanie form request przy implementacji API w Laravelu
Wykorzystanie form request przy implementacji API w LaraveluWykorzystanie form request przy implementacji API w Laravelu
Wykorzystanie form request przy implementacji API w Laravelu
 
Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)
 
Laravel Beginners Tutorial 1
Laravel Beginners Tutorial 1Laravel Beginners Tutorial 1
Laravel Beginners Tutorial 1
 
Intro to Laravel 4
Intro to Laravel 4Intro to Laravel 4
Intro to Laravel 4
 
Datagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and BackgridDatagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and Backgrid
 
Symfony2 Introduction Presentation
Symfony2 Introduction PresentationSymfony2 Introduction Presentation
Symfony2 Introduction Presentation
 
Alfresco study37 alfresco_ng2_components
Alfresco study37 alfresco_ng2_componentsAlfresco study37 alfresco_ng2_components
Alfresco study37 alfresco_ng2_components
 
Desenvolvendo uma aplicação híbrida para Android e IOs utilizando Ionic, aces...
Desenvolvendo uma aplicação híbrida para Android e IOs utilizando Ionic, aces...Desenvolvendo uma aplicação híbrida para Android e IOs utilizando Ionic, aces...
Desenvolvendo uma aplicação híbrida para Android e IOs utilizando Ionic, aces...
 
Getting started with Salesforce DX & CLI
Getting started with Salesforce DX & CLIGetting started with Salesforce DX & CLI
Getting started with Salesforce DX & CLI
 
Learn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutesLearn Dashing Widget in 90 minutes
Learn Dashing Widget in 90 minutes
 
A few good JavaScript development tools
A few good JavaScript development toolsA few good JavaScript development tools
A few good JavaScript development tools
 
Voiture tech talk
Voiture tech talkVoiture tech talk
Voiture tech talk
 
Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)
 
Add new commands in appium 2.0
Add new commands in appium 2.0Add new commands in appium 2.0
Add new commands in appium 2.0
 
Laravel for Web Artisans
Laravel for Web ArtisansLaravel for Web Artisans
Laravel for Web Artisans
 
Plugin development wpmeetup010
Plugin development wpmeetup010Plugin development wpmeetup010
Plugin development wpmeetup010
 
Manage appium dependencies with -appium-home in appium 2.0
Manage appium dependencies with  -appium-home in appium 2.0Manage appium dependencies with  -appium-home in appium 2.0
Manage appium dependencies with -appium-home in appium 2.0
 
Scalable web application architecture
Scalable web application architectureScalable web application architecture
Scalable web application architecture
 
RESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroRESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher Pecoraro
 

Viewers also liked

PyData - Consumindo e publicando web APIs com Python
PyData - Consumindo e publicando web APIs com PythonPyData - Consumindo e publicando web APIs com Python
PyData - Consumindo e publicando web APIs com Python
Bruno Rocha
 
Dynamically Generate a CRUD Admin Panel with Java Annotations
Dynamically Generate a CRUD Admin Panel with Java AnnotationsDynamically Generate a CRUD Admin Panel with Java Annotations
Dynamically Generate a CRUD Admin Panel with Java Annotations
Broadleaf Commerce
 
Play Framework on Google App Engine
Play Framework on Google App EnginePlay Framework on Google App Engine
Play Framework on Google App Engine
Fred Lin
 
Flask admin vs. DIY
Flask admin vs. DIYFlask admin vs. DIY
Flask admin vs. DIYdokenzy
 
Django para portais de alta visibilidade. tdc 2013
Django para portais de alta visibilidade.   tdc 2013Django para portais de alta visibilidade.   tdc 2013
Django para portais de alta visibilidade. tdc 2013Bruno Rocha
 
Web develop in flask
Web develop in flaskWeb develop in flask
Web develop in flask
Jim Yeh
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
Max Claus Nunes
 
When to use Node? Lessons learned
When to use Node? Lessons learnedWhen to use Node? Lessons learned
When to use Node? Lessons learned
beatlevic
 

Viewers also liked (8)

PyData - Consumindo e publicando web APIs com Python
PyData - Consumindo e publicando web APIs com PythonPyData - Consumindo e publicando web APIs com Python
PyData - Consumindo e publicando web APIs com Python
 
Dynamically Generate a CRUD Admin Panel with Java Annotations
Dynamically Generate a CRUD Admin Panel with Java AnnotationsDynamically Generate a CRUD Admin Panel with Java Annotations
Dynamically Generate a CRUD Admin Panel with Java Annotations
 
Play Framework on Google App Engine
Play Framework on Google App EnginePlay Framework on Google App Engine
Play Framework on Google App Engine
 
Flask admin vs. DIY
Flask admin vs. DIYFlask admin vs. DIY
Flask admin vs. DIY
 
Django para portais de alta visibilidade. tdc 2013
Django para portais de alta visibilidade.   tdc 2013Django para portais de alta visibilidade.   tdc 2013
Django para portais de alta visibilidade. tdc 2013
 
Web develop in flask
Web develop in flaskWeb develop in flask
Web develop in flask
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
 
When to use Node? Lessons learned
When to use Node? Lessons learnedWhen to use Node? Lessons learned
When to use Node? Lessons learned
 

Similar to What The Flask? and how to use it with some Google APIs

Django web framework
Django web frameworkDjango web framework
Django web framework
Abdenour Bouateli
 
JCConf 2016 - Dataflow Workshop Labs
JCConf 2016 - Dataflow Workshop LabsJCConf 2016 - Dataflow Workshop Labs
JCConf 2016 - Dataflow Workshop Labs
Simon Su
 
Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture Introduction
Haiqi Chen
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
Joaquim Rocha
 
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Edureka!
 
Build Secure Cloud-Hosted Apps for SharePoint 2013
Build Secure Cloud-Hosted Apps for SharePoint 2013Build Secure Cloud-Hosted Apps for SharePoint 2013
Build Secure Cloud-Hosted Apps for SharePoint 2013
Danny Jessee
 
Filling the flask
Filling the flaskFilling the flask
Filling the flask
Jason Myers
 
Pyramid Lighter/Faster/Better web apps
Pyramid Lighter/Faster/Better web appsPyramid Lighter/Faster/Better web apps
Pyramid Lighter/Faster/Better web apps
Dylan Jay
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
Francois Zaninotto
 
Gwt.create
Gwt.createGwt.create
Django tricks (2)
Django tricks (2)Django tricks (2)
Django tricks (2)
Carlos Hernando
 
بررسی چارچوب جنگو
بررسی چارچوب جنگوبررسی چارچوب جنگو
بررسی چارچوب جنگو
railsbootcamp
 
Pyramid Deployment and Maintenance
Pyramid Deployment and MaintenancePyramid Deployment and Maintenance
Pyramid Deployment and Maintenance
Jazkarta, Inc.
 
django_introduction20141030
django_introduction20141030django_introduction20141030
django_introduction20141030Kevin Wu
 
DJango
DJangoDJango
DJango
Sunil OS
 
Flask intro - ROSEdu web workshops
Flask intro - ROSEdu web workshopsFlask intro - ROSEdu web workshops
Flask intro - ROSEdu web workshops
Alex Eftimie
 
Automated User Tests with Apache Flex
Automated User Tests with Apache FlexAutomated User Tests with Apache Flex
Automated User Tests with Apache Flex
Gert Poppe
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API's
Antônio Roberto Silva
 
Performance and Scalability Testing with Python and Multi-Mechanize
Performance and Scalability Testing with Python and Multi-MechanizePerformance and Scalability Testing with Python and Multi-Mechanize
Performance and Scalability Testing with Python and Multi-Mechanize
coreygoldberg
 

Similar to What The Flask? and how to use it with some Google APIs (20)

Django web framework
Django web frameworkDjango web framework
Django web framework
 
JCConf 2016 - Dataflow Workshop Labs
JCConf 2016 - Dataflow Workshop LabsJCConf 2016 - Dataflow Workshop Labs
JCConf 2016 - Dataflow Workshop Labs
 
Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture Introduction
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
 
Build Secure Cloud-Hosted Apps for SharePoint 2013
Build Secure Cloud-Hosted Apps for SharePoint 2013Build Secure Cloud-Hosted Apps for SharePoint 2013
Build Secure Cloud-Hosted Apps for SharePoint 2013
 
Filling the flask
Filling the flaskFilling the flask
Filling the flask
 
Pyramid Lighter/Faster/Better web apps
Pyramid Lighter/Faster/Better web appsPyramid Lighter/Faster/Better web apps
Pyramid Lighter/Faster/Better web apps
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
 
Django introduction
Django introductionDjango introduction
Django introduction
 
Gwt.create
Gwt.createGwt.create
Gwt.create
 
Django tricks (2)
Django tricks (2)Django tricks (2)
Django tricks (2)
 
بررسی چارچوب جنگو
بررسی چارچوب جنگوبررسی چارچوب جنگو
بررسی چارچوب جنگو
 
Pyramid Deployment and Maintenance
Pyramid Deployment and MaintenancePyramid Deployment and Maintenance
Pyramid Deployment and Maintenance
 
django_introduction20141030
django_introduction20141030django_introduction20141030
django_introduction20141030
 
DJango
DJangoDJango
DJango
 
Flask intro - ROSEdu web workshops
Flask intro - ROSEdu web workshopsFlask intro - ROSEdu web workshops
Flask intro - ROSEdu web workshops
 
Automated User Tests with Apache Flex
Automated User Tests with Apache FlexAutomated User Tests with Apache Flex
Automated User Tests with Apache Flex
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API's
 
Performance and Scalability Testing with Python and Multi-Mechanize
Performance and Scalability Testing with Python and Multi-MechanizePerformance and Scalability Testing with Python and Multi-Mechanize
Performance and Scalability Testing with Python and Multi-Mechanize
 

More from Bruno Rocha

Escrevendo modulos python com rust
Escrevendo modulos python com rustEscrevendo modulos python com rust
Escrevendo modulos python com rust
Bruno Rocha
 
The quality of the python ecosystem - and how we can protect it!
The quality of the python ecosystem - and how we can protect it!The quality of the python ecosystem - and how we can protect it!
The quality of the python ecosystem - and how we can protect it!
Bruno Rocha
 
A Qualidade do Ecossistema Python - e o que podemos fazer para mante-la
A Qualidade do Ecossistema Python - e o que podemos fazer para mante-laA Qualidade do Ecossistema Python - e o que podemos fazer para mante-la
A Qualidade do Ecossistema Python - e o que podemos fazer para mante-la
Bruno Rocha
 
Quokka CMS - Desenvolvendo web apps com Flask e MongoDB - grupy - Outubro 2015
Quokka CMS - Desenvolvendo web apps com Flask e MongoDB - grupy - Outubro 2015Quokka CMS - Desenvolvendo web apps com Flask e MongoDB - grupy - Outubro 2015
Quokka CMS - Desenvolvendo web apps com Flask e MongoDB - grupy - Outubro 2015
Bruno Rocha
 
Data Developer - Engenharia de Dados em um time de Data Science - Uai python2015
Data Developer - Engenharia de Dados em um time de Data Science - Uai python2015Data Developer - Engenharia de Dados em um time de Data Science - Uai python2015
Data Developer - Engenharia de Dados em um time de Data Science - Uai python2015
Bruno Rocha
 
Carreira de Programador e Mercado de Trabalho
Carreira de Programador e Mercado de TrabalhoCarreira de Programador e Mercado de Trabalho
Carreira de Programador e Mercado de Trabalho
Bruno Rocha
 
Quokka CMS - Content Management with Flask and Mongo #tdc2014
Quokka CMS - Content Management with Flask and Mongo #tdc2014Quokka CMS - Content Management with Flask and Mongo #tdc2014
Quokka CMS - Content Management with Flask and Mongo #tdc2014
Bruno Rocha
 
Web Crawling Modeling with Scrapy Models #TDC2014
Web Crawling Modeling with Scrapy Models #TDC2014Web Crawling Modeling with Scrapy Models #TDC2014
Web Crawling Modeling with Scrapy Models #TDC2014
Bruno Rocha
 
Flask for CMS/App Framework development.
Flask for CMS/App Framework development.Flask for CMS/App Framework development.
Flask for CMS/App Framework development.
Bruno Rocha
 
Desenvolvendo mvp com python
Desenvolvendo mvp com pythonDesenvolvendo mvp com python
Desenvolvendo mvp com python
Bruno Rocha
 
Flask Full Stack - Desenvolvendo um CMS com Flask e MongoDB
Flask Full Stack - Desenvolvendo um CMS com Flask e MongoDBFlask Full Stack - Desenvolvendo um CMS com Flask e MongoDB
Flask Full Stack - Desenvolvendo um CMS com Flask e MongoDB
Bruno Rocha
 
Guia alimentar de dietas vegetarianas para adultos
Guia alimentar de dietas vegetarianas para adultosGuia alimentar de dietas vegetarianas para adultos
Guia alimentar de dietas vegetarianas para adultos
Bruno Rocha
 
Desmistificando web2py - #TDC2011
Desmistificando web2py - #TDC2011Desmistificando web2py - #TDC2011
Desmistificando web2py - #TDC2011Bruno Rocha
 
Using web2py's DAL in other projects or frameworks
Using web2py's DAL in other projects or frameworksUsing web2py's DAL in other projects or frameworks
Using web2py's DAL in other projects or frameworks
Bruno Rocha
 
Desenvolvimento web ágil com Python e web2py #qconsp #qcon
Desenvolvimento web ágil com Python e web2py #qconsp #qconDesenvolvimento web ágil com Python e web2py #qconsp #qcon
Desenvolvimento web ágil com Python e web2py #qconsp #qcon
Bruno Rocha
 

More from Bruno Rocha (15)

Escrevendo modulos python com rust
Escrevendo modulos python com rustEscrevendo modulos python com rust
Escrevendo modulos python com rust
 
The quality of the python ecosystem - and how we can protect it!
The quality of the python ecosystem - and how we can protect it!The quality of the python ecosystem - and how we can protect it!
The quality of the python ecosystem - and how we can protect it!
 
A Qualidade do Ecossistema Python - e o que podemos fazer para mante-la
A Qualidade do Ecossistema Python - e o que podemos fazer para mante-laA Qualidade do Ecossistema Python - e o que podemos fazer para mante-la
A Qualidade do Ecossistema Python - e o que podemos fazer para mante-la
 
Quokka CMS - Desenvolvendo web apps com Flask e MongoDB - grupy - Outubro 2015
Quokka CMS - Desenvolvendo web apps com Flask e MongoDB - grupy - Outubro 2015Quokka CMS - Desenvolvendo web apps com Flask e MongoDB - grupy - Outubro 2015
Quokka CMS - Desenvolvendo web apps com Flask e MongoDB - grupy - Outubro 2015
 
Data Developer - Engenharia de Dados em um time de Data Science - Uai python2015
Data Developer - Engenharia de Dados em um time de Data Science - Uai python2015Data Developer - Engenharia de Dados em um time de Data Science - Uai python2015
Data Developer - Engenharia de Dados em um time de Data Science - Uai python2015
 
Carreira de Programador e Mercado de Trabalho
Carreira de Programador e Mercado de TrabalhoCarreira de Programador e Mercado de Trabalho
Carreira de Programador e Mercado de Trabalho
 
Quokka CMS - Content Management with Flask and Mongo #tdc2014
Quokka CMS - Content Management with Flask and Mongo #tdc2014Quokka CMS - Content Management with Flask and Mongo #tdc2014
Quokka CMS - Content Management with Flask and Mongo #tdc2014
 
Web Crawling Modeling with Scrapy Models #TDC2014
Web Crawling Modeling with Scrapy Models #TDC2014Web Crawling Modeling with Scrapy Models #TDC2014
Web Crawling Modeling with Scrapy Models #TDC2014
 
Flask for CMS/App Framework development.
Flask for CMS/App Framework development.Flask for CMS/App Framework development.
Flask for CMS/App Framework development.
 
Desenvolvendo mvp com python
Desenvolvendo mvp com pythonDesenvolvendo mvp com python
Desenvolvendo mvp com python
 
Flask Full Stack - Desenvolvendo um CMS com Flask e MongoDB
Flask Full Stack - Desenvolvendo um CMS com Flask e MongoDBFlask Full Stack - Desenvolvendo um CMS com Flask e MongoDB
Flask Full Stack - Desenvolvendo um CMS com Flask e MongoDB
 
Guia alimentar de dietas vegetarianas para adultos
Guia alimentar de dietas vegetarianas para adultosGuia alimentar de dietas vegetarianas para adultos
Guia alimentar de dietas vegetarianas para adultos
 
Desmistificando web2py - #TDC2011
Desmistificando web2py - #TDC2011Desmistificando web2py - #TDC2011
Desmistificando web2py - #TDC2011
 
Using web2py's DAL in other projects or frameworks
Using web2py's DAL in other projects or frameworksUsing web2py's DAL in other projects or frameworks
Using web2py's DAL in other projects or frameworks
 
Desenvolvimento web ágil com Python e web2py #qconsp #qcon
Desenvolvimento web ágil com Python e web2py #qconsp #qconDesenvolvimento web ágil com Python e web2py #qconsp #qcon
Desenvolvimento web ágil com Python e web2py #qconsp #qcon
 

Recently uploaded

Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 

Recently uploaded (20)

Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 

What The Flask? and how to use it with some Google APIs

  • 3. Full Stack Framework Faz as escolhas por você e oferece uma plataforma completa Micro Framework Define apenas o básico (WSGI, request, response, session etc) (ORM, Templates, Organização de arquivos, arquivos de configurações, etc) + Fácil - controle Crescimento gradativo + trabalhoso + controle
  • 4. What The Flask? Flask is a microframework for Python based on Werkzeug, Jinja 2 and good intentions.
  • 5. Werkzeug - WSGI library from werkzeug.serving import run_simple from werkzeug.wrappers import Request, Response @Request.application def application(request): return Response('Hello World!') run_simple('localhost', 4000, application)
  • 6. Jinja - Template engine {% macro render_user(user) %} <li><a href="{{ user.url }}">{{ user.username }}</a></li> {% endmacro %} {% from _above_file.html import render_user %} <title>{% block title %}{% endblock %}</title> <ul> {% for user in users %} {{ render_user(user) }} {% endfor %} </ul>
  • 7. Good intentions. # thread locals from flask import request, session, g # extensions from flask.ext import AmazingExtension # blueprints from flask import Blueprint blog = Blueprint(“blog_blueprint”) blog.template_folder = “path/to/folder” blog.static_folder = “path/to/static” # Application factory app = create_app(**kwargs) app.register_blueprint(blog) AmazingExtension(app)
  • 8. It is not a framework, it is a pattern! Good intentions flask.ext.* your_app.py
  • 9. your_app.py $ pip install flask, flask-security, flask-admin, xpto-orm from from from from from flask import Flask flask.ext.security import Security flask.ext.admin import Admin somewhere.db.models import UserDatastore somewhere.views import indexpage def create_app(**config): app = Flask(“myapp”) app.config_from_object(config) Admin(app) Security(app, UserDatastore) app.add_url_rule(“/index/<something>”, view_func=indexpage) return app if __name__ == “__main__”: app = create_app(SECRET_KEY=”XYZ”) app.run()
  • 10. Blueprints Um Blueprint funciona de forma similar a um objeto Flask, mas na verdade não é uma aplicação, mas sim um projeto de como construir ou extender uma aplicação from flask import Blueprint, render_template blog_extension = Blueprint(“my_blog_extension”) blog_extension.endpoint = “/blog” blog_extension.template_folder = “path/to/blog_templates” blog_extension.static_folder = “path/to/blog_static” @blog_extension.route(“/index”) def blog(): posts = some_db_or_orm.posts.query() return render_template(“blog.html”, posts=posts) blog_blueprint.py from blog_blueprint import blog_extension your_app.py def create_app(**config): app = Flask(“myapp”) ... app.register_blueprint(blog_extension) return app
  • 11. ● ● Flask subclass ○ class MyOwnFlask(Flask): pass application factory ○ app = create_app(**config) ○ evitar import circular ● Blueprints ○ Mesmo que seja uma one-page-app ● Flask-Admin ○ Modular, insira qualquer view no admin, crud completo, actions, filters ● Flask-Security ○ Login, Logout, Lembrar senha, Register, Access control, permissions ● Flask-script ○ python manage.py faça_me_um_sanduiche ● app.config_from_envvar ○ Settings desacoplado da app ○ export APP_SETTINGS=”/path/to/settings.cfg” ○ app.config_from_envvar(“APP_SETTINGS”)
  • 13. http://bit.ly/flask-gae # app.yaml application : nome_do_app version : 1 runtime : python27 api_version : 1 threadsafe: true libraries: - name: jinja2 version: "2.6" - name: markupsafe version: "0.15" handlers: - url: /static static_dir : your_app_folder/static - url: .* script : main.app # your_app.py from flask import Flask def create_app(): app = Flask(__name__) return app # main.py from werkzeug import DebuggedApplication from your_app import create_app app = DebuggedApplication(create_app())
  • 14. https://github.com/sashka/flask-googleauth # your_app.py from flask import Flask from flask.ext.googleauth import GoogleFederated from .configurator import register_views def create_app(): app = Flask(__name__) app.secret_key = “XYZ” auth = GoogleFederated("dominio.com", app) register_views(app, auth) return app # configurator.py from .views import myview, …, ... def register_views(app, auth) secret = auth.required(myview) app.add_url_rule(“/secret/”, view_func=secret) … ... # views.py from flask import g def myview() return "Logged user, %s (%s)" % (g.user.name, g.user.email) … ...
  • 15. github.com/rochacbruno/Flask-GoogleMaps pip install flask-googlemaps from flask import Flask from flask.ext.googlemaps import GoogleMaps app = Flask(__name__) GoogleMaps(app) <div> {{googlemap("my_awesome_map", 0.23234234, -0.234234234, markers=[(0.12, -0.45345), ...])}} </div>