SlideShare uma empresa Scribd logo
1 de 20
Baixar para ler offline
FLASK - BACKEND COM
PYTHON
SIBELIUS SERAPHINI
2010-2015 Bacharel em Ciências de Computação
2015
Full Stack Developer
O QUE É BACKEND?
Backend
Frontend
Mobile
Database
LET’S CODE
VIRTUALENV
# Cria um virtualenv com nome hello com Python3
mkvirtualenv hello -p /usr/local/bin/python3
# Lista virtualenvs
workon
# inicia virtualenv hello
workon hello
# desativa virtualenv
deactivate
#!/usr/bin/env python3
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello SemComp!'
if __name__ == '__main__':
app.run()
$ pip install Flask
$ python hello.py
* Running on http://localhost:5000/
git clone https://github.com/sibeliusseraphini/hello-flask.git
DEPLOY TO
1. Criar um app no Heroku - heroku apps:create semcomp18
2. Adicionar runtime.txt - python-3.4.2
3. Adicionar Procfile - web: uwsgi uwsgi.ini
4. Install uWSGI - pip install uwsgi
5. Adicionar configuração do uWSGI - uwsgi.ini
6. Criar requirements.txt - pip freeze > requirements.txt
7. Realizar release - git push heroku master
[uwsgi]
http-socket = :$(PORT)
master = true
processes = 8
threads = 4
die-on-term = true
module = hello:app
memory-report = true
offline-threads = 4
harakiri = 500
harakiri-verbose = true
ESTRUTURA FLASK
├── Procfile
├── manage.py
├── requirements.txt
├── runtime.txt
├── semcomp
│   ├── __init__.py
│   ├── api
│   │   ├── __init__.py
│   │   ├── routes.py
│   │   └── tarefa.py
│   ├── main
│   │   ├── __init__.py
│   │   ├── errors.py
│   │   └── views.py
│   ├── models.py
│   ├── static
│   └── templates
│   └── 404.jade
│   └── base.html
└── uwsgi.ini
App Grande
git clone https://github.com/sibeliusseraphini/semcomp-flask.git
BLUEPRINT
api - www.mywebpage.com/api
admin - www.mywebpage.com/admin
mobile - www.mywebpage.com/mobile
•Modular apps
from . import main
from flask import render_template
@main.route('/')
def index():
return "It's working
@main.route('/hello/<name>')
def hello(name):
return render_template('hello.html', name=name)
STATIC FILES + TEMPLATES
from flask import render_template
from . import main
@main.route('/hello/<name>')
def hello(name):
return render_template('hello.html', name=name)
•static files - app/static
•templates - app/templates
JINJA2 - TEMPLATING
<title>{% block title %}{% endblock %}</title>
<ul>
{% for user in users %}
<li><a href="{{ user.url }}">{{ user.username }}</a></li>
{% endfor %}
</ul>
JADE
<!DOCTYPE html>
<html lang="en">
<head>
<title>Jade</title>
<script type="text/javascript">
if (foo) {
bar(1 + 5)
}
</script>
</head>
<body>
<h1>Jade - node template engine</h1>
<div id="container" class="col">
<p>You are amazing</p>
<p>
Jade is a terse and simple
templating language with a
strong focus on performance
and powerful features.
</p>
</div>
</body>
</html>
doctype html
html(lang="en")
head
title= pageTitle
script(type='text/javascript').
if (foo) {
bar(1 + 5)
}
body
h1 Jade - node template engine
#container.col
if youAreUsingJade
p You are amazing
else
p Get on it!
p.
Jade is a terse and simple
templating language with a
strong focus on performance
and powerful features.
PYJADE (JINJA2 + JADE)
app.jinja_env.add_extension(‘pyjade.ext.jinja.PyJadeExtension')
pip install pyjade
ERROR HANDLING
from flask import render_template
from . import main
@main.app_errorhandler(404)
def page_not_found(e):
return render_template('404.jade'), 404
•404 Not Found
•403 Forbidden
•410 Gone
•500 Internal Server Error
EXTENSÕES
Flask-Script - scripts externos
Flask-RESTful - REST APIs fácil
Flask-JWT - autenticação por token JWT
Flask-Weasyprint - HTML as PDF
Flask-Mail - email para Flask
Flask-Login - gerenciamento de sessão de usuário
MONGODB
PyMongo - Mongoengine
REST
GET /api/tarefa - retorna todas as tarefas
GET /api/tarefa/:id - retorna a tarefa :id
PUT /api/tarefa/:id - atualiza a tarefa :id
DELETE /api/tarefa/:id - delete/remove tarefa :id
POST /api/tarefa - cria uma nova tarefa
REST
Sem extensões
REST
Com extensões

Mais conteúdo relacionado

Mais procurados

Dance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech TalkDance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech Talk
Michael Peacock
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friends
Michael Peacock
 

Mais procurados (20)

LvivPy - Flask in details
LvivPy - Flask in detailsLvivPy - Flask in details
LvivPy - Flask in details
 
Flask RESTful Flask HTTPAuth
Flask RESTful Flask HTTPAuthFlask RESTful Flask HTTPAuth
Flask RESTful Flask HTTPAuth
 
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...
 
Web develop in flask
Web develop in flaskWeb develop in flask
Web develop in flask
 
Rest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemyRest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemy
 
Rest api with Python
Rest api with PythonRest api with Python
Rest api with Python
 
#30.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#30.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...#30.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#30.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
 
Getting Started-with-Laravel
Getting Started-with-LaravelGetting Started-with-Laravel
Getting Started-with-Laravel
 
Flask SQLAlchemy
Flask SQLAlchemy Flask SQLAlchemy
Flask SQLAlchemy
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5
 
Laravel Design Patterns
Laravel Design PatternsLaravel Design Patterns
Laravel Design Patterns
 
Dance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech TalkDance for the puppet master: G6 Tech Talk
Dance for the puppet master: G6 Tech Talk
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
Djangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 Minutes
Djangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 MinutesDjangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 Minutes
Djangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 Minutes
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friends
 
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
 
OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010
 
REST APIs in Laravel 101
REST APIs in Laravel 101REST APIs in Laravel 101
REST APIs in Laravel 101
 
CodeIgniter 3.0
CodeIgniter 3.0CodeIgniter 3.0
CodeIgniter 3.0
 
Phinx talk
Phinx talkPhinx talk
Phinx talk
 

Semelhante a Flask - Backend com Python - Semcomp 18

Frameworks da nova Era PHP FuelPHP
Frameworks da nova Era PHP FuelPHPFrameworks da nova Era PHP FuelPHP
Frameworks da nova Era PHP FuelPHP
Dan Jesus
 
Prefixルーティングとthemeのススメ
PrefixルーティングとthemeのススメPrefixルーティングとthemeのススメ
Prefixルーティングとthemeのススメ
Shusuke Otomo
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHP
Nat Weerawan
 

Semelhante a Flask - Backend com Python - Semcomp 18 (20)

Flask-RESTPlusで便利なREST API開発 | Productive RESTful API development with Flask-...
Flask-RESTPlusで便利なREST API開発 | Productive RESTful API development with Flask-...Flask-RESTPlusで便利なREST API開発 | Productive RESTful API development with Flask-...
Flask-RESTPlusで便利なREST API開発 | Productive RESTful API development with Flask-...
 
Frameworks da nova Era PHP FuelPHP
Frameworks da nova Era PHP FuelPHPFrameworks da nova Era PHP FuelPHP
Frameworks da nova Era PHP FuelPHP
 
Flask Introduction - Python Meetup
Flask Introduction - Python MeetupFlask Introduction - Python Meetup
Flask Introduction - Python Meetup
 
Python para web - Utilizando micro-framework Flask - PUG-MA
Python para web - Utilizando micro-framework Flask - PUG-MAPython para web - Utilizando micro-framework Flask - PUG-MA
Python para web - Utilizando micro-framework Flask - PUG-MA
 
Pyramid Lighter/Faster/Better web apps
Pyramid Lighter/Faster/Better web appsPyramid Lighter/Faster/Better web apps
Pyramid Lighter/Faster/Better web apps
 
Symfony2 - OSIDays 2010
Symfony2 - OSIDays 2010Symfony2 - OSIDays 2010
Symfony2 - OSIDays 2010
 
Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010
 
Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010Symfony2 - WebExpo 2010
Symfony2 - WebExpo 2010
 
Prefixルーティングとthemeのススメ
PrefixルーティングとthemeのススメPrefixルーティングとthemeのススメ
Prefixルーティングとthemeのススメ
 
Laravel 101
Laravel 101Laravel 101
Laravel 101
 
PhpBB meets Symfony2
PhpBB meets Symfony2PhpBB meets Symfony2
PhpBB meets Symfony2
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2
 
Modular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJSModular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJS
 
Flask & Flask-restx
Flask & Flask-restxFlask & Flask-restx
Flask & Flask-restx
 
Flask intro - ROSEdu web workshops
Flask intro - ROSEdu web workshopsFlask intro - ROSEdu web workshops
Flask intro - ROSEdu web workshops
 
GettingStartedWithPHP
GettingStartedWithPHPGettingStartedWithPHP
GettingStartedWithPHP
 
Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!
 
Quality Use Of Plugin
Quality Use Of PluginQuality Use Of Plugin
Quality Use Of Plugin
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
Codeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept ImplementationCodeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept Implementation
 

Mais de Lar21

Mais de Lar21 (6)

Acumen Pitch - Sua Ideia na Prática (SINP) São Paulo - SP - Ideation Brasil
Acumen Pitch - Sua Ideia na Prática (SINP) São Paulo - SP - Ideation BrasilAcumen Pitch - Sua Ideia na Prática (SINP) São Paulo - SP - Ideation Brasil
Acumen Pitch - Sua Ideia na Prática (SINP) São Paulo - SP - Ideation Brasil
 
Constrained k means clustering with background knowledge - COP-Kmeans
Constrained k means clustering with background knowledge - COP-KmeansConstrained k means clustering with background knowledge - COP-Kmeans
Constrained k means clustering with background knowledge - COP-Kmeans
 
Reconhecendo atividades físicas utilizando um smartphone não rigidamente fi...
Reconhecendo atividades físicas utilizando um smartphone não rigidamente fi...Reconhecendo atividades físicas utilizando um smartphone não rigidamente fi...
Reconhecendo atividades físicas utilizando um smartphone não rigidamente fi...
 
Blind Verification of Digital Image Originality: A Statistical Approach
Blind Verification of Digital Image Originality: A Statistical ApproachBlind Verification of Digital Image Originality: A Statistical Approach
Blind Verification of Digital Image Originality: A Statistical Approach
 
FlexInterface: a Framework to Provide Flexible Mobile Phone User Interfaces -...
FlexInterface: a Framework to Provide Flexible Mobile Phone User Interfaces -...FlexInterface: a Framework to Provide Flexible Mobile Phone User Interfaces -...
FlexInterface: a Framework to Provide Flexible Mobile Phone User Interfaces -...
 
An Analytic Approach to Evaluate Flexible Mobile User Interfaces for the Elde...
An Analytic Approach to Evaluate Flexible Mobile User Interfaces for the Elde...An Analytic Approach to Evaluate Flexible Mobile User Interfaces for the Elde...
An Analytic Approach to Evaluate Flexible Mobile User Interfaces for the Elde...
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 

Flask - Backend com Python - Semcomp 18

  • 1. FLASK - BACKEND COM PYTHON
  • 2. SIBELIUS SERAPHINI 2010-2015 Bacharel em Ciências de Computação 2015 Full Stack Developer
  • 3. O QUE É BACKEND?
  • 6. VIRTUALENV # Cria um virtualenv com nome hello com Python3 mkvirtualenv hello -p /usr/local/bin/python3 # Lista virtualenvs workon # inicia virtualenv hello workon hello # desativa virtualenv deactivate
  • 7. #!/usr/bin/env python3 from flask import Flask app = Flask(__name__) @app.route('/') def hello(): return 'Hello SemComp!' if __name__ == '__main__': app.run() $ pip install Flask $ python hello.py * Running on http://localhost:5000/ git clone https://github.com/sibeliusseraphini/hello-flask.git
  • 8. DEPLOY TO 1. Criar um app no Heroku - heroku apps:create semcomp18 2. Adicionar runtime.txt - python-3.4.2 3. Adicionar Procfile - web: uwsgi uwsgi.ini 4. Install uWSGI - pip install uwsgi 5. Adicionar configuração do uWSGI - uwsgi.ini 6. Criar requirements.txt - pip freeze > requirements.txt 7. Realizar release - git push heroku master [uwsgi] http-socket = :$(PORT) master = true processes = 8 threads = 4 die-on-term = true module = hello:app memory-report = true offline-threads = 4 harakiri = 500 harakiri-verbose = true
  • 9. ESTRUTURA FLASK ├── Procfile ├── manage.py ├── requirements.txt ├── runtime.txt ├── semcomp │   ├── __init__.py │   ├── api │   │   ├── __init__.py │   │   ├── routes.py │   │   └── tarefa.py │   ├── main │   │   ├── __init__.py │   │   ├── errors.py │   │   └── views.py │   ├── models.py │   ├── static │   └── templates │   └── 404.jade │   └── base.html └── uwsgi.ini App Grande git clone https://github.com/sibeliusseraphini/semcomp-flask.git
  • 10. BLUEPRINT api - www.mywebpage.com/api admin - www.mywebpage.com/admin mobile - www.mywebpage.com/mobile •Modular apps from . import main from flask import render_template @main.route('/') def index(): return "It's working @main.route('/hello/<name>') def hello(name): return render_template('hello.html', name=name)
  • 11. STATIC FILES + TEMPLATES from flask import render_template from . import main @main.route('/hello/<name>') def hello(name): return render_template('hello.html', name=name) •static files - app/static •templates - app/templates
  • 12. JINJA2 - TEMPLATING <title>{% block title %}{% endblock %}</title> <ul> {% for user in users %} <li><a href="{{ user.url }}">{{ user.username }}</a></li> {% endfor %} </ul>
  • 13. JADE <!DOCTYPE html> <html lang="en"> <head> <title>Jade</title> <script type="text/javascript"> if (foo) { bar(1 + 5) } </script> </head> <body> <h1>Jade - node template engine</h1> <div id="container" class="col"> <p>You are amazing</p> <p> Jade is a terse and simple templating language with a strong focus on performance and powerful features. </p> </div> </body> </html> doctype html html(lang="en") head title= pageTitle script(type='text/javascript'). if (foo) { bar(1 + 5) } body h1 Jade - node template engine #container.col if youAreUsingJade p You are amazing else p Get on it! p. Jade is a terse and simple templating language with a strong focus on performance and powerful features.
  • 14. PYJADE (JINJA2 + JADE) app.jinja_env.add_extension(‘pyjade.ext.jinja.PyJadeExtension') pip install pyjade
  • 15. ERROR HANDLING from flask import render_template from . import main @main.app_errorhandler(404) def page_not_found(e): return render_template('404.jade'), 404 •404 Not Found •403 Forbidden •410 Gone •500 Internal Server Error
  • 16. EXTENSÕES Flask-Script - scripts externos Flask-RESTful - REST APIs fácil Flask-JWT - autenticação por token JWT Flask-Weasyprint - HTML as PDF Flask-Mail - email para Flask Flask-Login - gerenciamento de sessão de usuário
  • 18. REST GET /api/tarefa - retorna todas as tarefas GET /api/tarefa/:id - retorna a tarefa :id PUT /api/tarefa/:id - atualiza a tarefa :id DELETE /api/tarefa/:id - delete/remove tarefa :id POST /api/tarefa - cria uma nova tarefa