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 (20)

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

Viewers also liked (8)

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

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

PDF
Introduction to Flask Micro Framework
Mohammad Reza Kamalifard
 
PDF
Flask - Backend com Python - Semcomp 18
Lar21
 
PPTX
Flask-Python
Triloki Gupta
 
PDF
Kyiv.py #17 Flask talk
Alexey Popravka
 
PDF
Webapp2 2.2
Sergi Duró
 
PDF
Python Web Applications With Flask Handon Your Flask Skills2024 Jeffrey Leon ...
keyroreagan
 
PPTX
Flask & Flask-restx
ammaraslam18
 
PPTX
Flask Application ppt to understand the flask
vijoho5545
 
PDF
Django for mobile applications
Hassan Abid
 
PDF
EuroPython 2013 - Python3 TurboGears Training
Alessandro Molina
 
PDF
Flask patterns
it-people
 
PPTX
Building a local web application with Flask
Hoffman Lab
 
PPTX
Flask and Introduction to web frameworks
dipendralfs
 
PPTX
Build restful ap is with python and flask
Jeetendra singh
 
PPTX
Flask_basics.pptx
AkshayRevankar16
 
PDF
Web frameworks in python
Knowledgehut
 
PDF
Behind the curtain - How Django handles a request
Daniel Hepper
 
PDF
Flask intro - ROSEdu web workshops
Alex Eftimie
 
PDF
BUILDING MODERN PYTHON WEB FRAMEWORKS USING FLASK WITH NEIL GREY
CodeCore
 
Introduction to Flask Micro Framework
Mohammad Reza Kamalifard
 
Flask - Backend com Python - Semcomp 18
Lar21
 
Flask-Python
Triloki Gupta
 
Kyiv.py #17 Flask talk
Alexey Popravka
 
Webapp2 2.2
Sergi Duró
 
Python Web Applications With Flask Handon Your Flask Skills2024 Jeffrey Leon ...
keyroreagan
 
Flask & Flask-restx
ammaraslam18
 
Flask Application ppt to understand the flask
vijoho5545
 
Django for mobile applications
Hassan Abid
 
EuroPython 2013 - Python3 TurboGears Training
Alessandro Molina
 
Flask patterns
it-people
 
Building a local web application with Flask
Hoffman Lab
 
Flask and Introduction to web frameworks
dipendralfs
 
Build restful ap is with python and flask
Jeetendra singh
 
Flask_basics.pptx
AkshayRevankar16
 
Web frameworks in python
Knowledgehut
 
Behind the curtain - How Django handles a request
Daniel Hepper
 
Flask intro - ROSEdu web workshops
Alex Eftimie
 
BUILDING MODERN PYTHON WEB FRAMEWORKS USING FLASK WITH NEIL GREY
CodeCore
 
Ad

More from Bruno Rocha (15)

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

Recently uploaded (20)

PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 

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