SlideShare uma empresa Scribd logo
1 de 14
Baixar para ler offline
REST in Flask
                                raising
 the
 service




I am: Yehor Nazarkin
Follow me: @nimnull
Email me: nimnull@gmail.com
Saturday, June 2, 12
RESTin
 pieces

                            • Representative state transfer

                            • Hypertext transfer protocol:
                                     ✓ URL endpoint as resource address

                                     ✓ Content-Type

                                     ✓ Status codes

                            • The Web is REST




Saturday, June 2, 12
RESTin
 pieces

                              Web Front                       Mobile client



                                                        API



                                                       Backends


Saturday, June 2, 12
Why Flask? as
 we
 already
 have
 tones
 of
 stuff
                              • I’m not a framework junkie

                              • I want to customize, not rewrite

                              • Clean codebase (20 python modules)

                              • Aware of django.contrib.admin, django.form, etc.

                              • Lack of ORM functionality

                                             ✓ I don’t like to write raw SQL
                                             ✓ I need composite keys
                                             ✓ I want to optimize for a DB backend (we are
                                               on PostgreSQL)




Saturday, June 2, 12

Mais conteúdo relacionado

Mais procurados

Web2py tutorial to create db driven application.
Web2py tutorial to create db driven application.Web2py tutorial to create db driven application.
Web2py tutorial to create db driven application.
fRui Apps
 
Web2py Code Lab
Web2py Code LabWeb2py Code Lab
Web2py Code Lab
Colin Su
 
Flask patterns
Flask patternsFlask patterns
Flask patterns
it-people
 

Mais procurados (20)

Elegant Solutions For Everyday Python Problems - Nina Zakharenko
Elegant Solutions For Everyday Python Problems - Nina ZakharenkoElegant Solutions For Everyday Python Problems - Nina Zakharenko
Elegant Solutions For Everyday Python Problems - Nina Zakharenko
 
Filling the flask
Filling the flaskFilling the flask
Filling the flask
 
Why Every Tester Should Learn Ruby
Why Every Tester Should Learn RubyWhy Every Tester Should Learn Ruby
Why Every Tester Should Learn Ruby
 
Eve - REST API for Humans™
Eve - REST API for Humans™Eve - REST API for Humans™
Eve - REST API for Humans™
 
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and JasmineRails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
 
Rails on Oracle 2011
Rails on Oracle 2011Rails on Oracle 2011
Rails on Oracle 2011
 
Testing Backbone applications with Jasmine
Testing Backbone applications with JasmineTesting Backbone applications with Jasmine
Testing Backbone applications with Jasmine
 
Django REST Framework
Django REST FrameworkDjango REST Framework
Django REST Framework
 
Redis for your boss 2.0
Redis for your boss 2.0Redis for your boss 2.0
Redis for your boss 2.0
 
Redis for your boss
Redis for your bossRedis for your boss
Redis for your boss
 
Introduction to Flask Micro Framework
Introduction to Flask Micro FrameworkIntroduction to Flask Micro Framework
Introduction to Flask Micro Framework
 
Web2py tutorial to create db driven application.
Web2py tutorial to create db driven application.Web2py tutorial to create db driven application.
Web2py tutorial to create db driven application.
 
Web2py Code Lab
Web2py Code LabWeb2py Code Lab
Web2py Code Lab
 
web2py:Web development like a boss
web2py:Web development like a bossweb2py:Web development like a boss
web2py:Web development like a boss
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - Keynote
 
Quebec pdo
Quebec pdoQuebec pdo
Quebec pdo
 
Flask patterns
Flask patternsFlask patterns
Flask patterns
 
And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
 
Swing database(mysql)
Swing database(mysql)Swing database(mysql)
Swing database(mysql)
 

Destaque

Destaque (20)

Developing RESTful Web APIs with Python, Flask and MongoDB
Developing RESTful Web APIs with Python, Flask and MongoDBDeveloping RESTful Web APIs with Python, Flask and MongoDB
Developing RESTful Web APIs with Python, Flask and MongoDB
 
Microservices with Swagger, Flask and Docker
Microservices with Swagger, Flask and DockerMicroservices with Swagger, Flask and Docker
Microservices with Swagger, Flask and Docker
 
Rest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemyRest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemy
 
Building Automated REST APIs with Python
Building Automated REST APIs with PythonBuilding Automated REST APIs with Python
Building Automated REST APIs with Python
 
ContainerDayVietnam2016: Django Development with Docker
ContainerDayVietnam2016: Django Development with DockerContainerDayVietnam2016: Django Development with Docker
ContainerDayVietnam2016: Django Development with Docker
 
Flask restless
Flask restlessFlask restless
Flask restless
 
Flask SQLAlchemy
Flask SQLAlchemy Flask SQLAlchemy
Flask SQLAlchemy
 
Rest in flask
Rest in flaskRest in flask
Rest in flask
 
BangML Meetup 1: The Path to Becoming an Machine Learning Expert
BangML Meetup 1: The Path to Becoming an Machine Learning ExpertBangML Meetup 1: The Path to Becoming an Machine Learning Expert
BangML Meetup 1: The Path to Becoming an Machine Learning Expert
 
Python Workshop Day - 2 (REVA University)
Python Workshop Day - 2 (REVA University)Python Workshop Day - 2 (REVA University)
Python Workshop Day - 2 (REVA University)
 
Learn flask in 90mins
Learn flask in 90minsLearn flask in 90mins
Learn flask in 90mins
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flask
 
AWS LearnUp - Intro to AWS Services - Venturesity
AWS LearnUp - Intro to AWS Services - VenturesityAWS LearnUp - Intro to AWS Services - Venturesity
AWS LearnUp - Intro to AWS Services - Venturesity
 
Open-E DSS V7 Active-Active Load Balanced iSCSI HA Cluster (with bonding)
Open-E DSS V7 Active-Active Load Balanced iSCSI HA Cluster (with bonding)Open-E DSS V7 Active-Active Load Balanced iSCSI HA Cluster (with bonding)
Open-E DSS V7 Active-Active Load Balanced iSCSI HA Cluster (with bonding)
 
Atlanta OpenStack 2014 Chef for OpenStack Deployment Workshop
Atlanta OpenStack 2014 Chef for OpenStack Deployment WorkshopAtlanta OpenStack 2014 Chef for OpenStack Deployment Workshop
Atlanta OpenStack 2014 Chef for OpenStack Deployment Workshop
 
Pycon 2008: Python Command-line Tools *Nix
Pycon 2008:  Python Command-line Tools *NixPycon 2008:  Python Command-line Tools *Nix
Pycon 2008: Python Command-line Tools *Nix
 
Red Hat Storage Day Seattle: Why Software-Defined Storage Matters
Red Hat Storage Day Seattle: Why Software-Defined Storage MattersRed Hat Storage Day Seattle: Why Software-Defined Storage Matters
Red Hat Storage Day Seattle: Why Software-Defined Storage Matters
 
OpenStack Deployment with Chef Workshop
OpenStack Deployment with Chef WorkshopOpenStack Deployment with Chef Workshop
OpenStack Deployment with Chef Workshop
 
Modern Web App Development using ClojureScript & React.js / Baishampayan “BG”...
Modern Web App Development using ClojureScript & React.js / Baishampayan “BG”...Modern Web App Development using ClojureScript & React.js / Baishampayan “BG”...
Modern Web App Development using ClojureScript & React.js / Baishampayan “BG”...
 
Introduction to Apache Synapse
Introduction to Apache SynapseIntroduction to Apache Synapse
Introduction to Apache Synapse
 

Semelhante a Rest in flask

Building Better Applications with Data::Manager
Building Better Applications with Data::ManagerBuilding Better Applications with Data::Manager
Building Better Applications with Data::Manager
Jay Shirley
 
Pinterest的数据库分片架构
Pinterest的数据库分片架构Pinterest的数据库分片架构
Pinterest的数据库分片架构
Tommy Chiu
 
Jan Lehnardt Couch Db In A Real World Setting
Jan Lehnardt Couch Db In A Real World SettingJan Lehnardt Couch Db In A Real World Setting
Jan Lehnardt Couch Db In A Real World Setting
George Ang
 
Enterprise javascriptsession3
Enterprise javascriptsession3Enterprise javascriptsession3
Enterprise javascriptsession3
Troy Miles
 
Authorship attribution pydata london
Authorship attribution   pydata londonAuthorship attribution   pydata london
Authorship attribution pydata london
kperi
 
Kicking ass with redis
Kicking ass with redisKicking ass with redis
Kicking ass with redis
Dvir Volk
 

Semelhante a Rest in flask (20)

Grails 2.0 Update
Grails 2.0 UpdateGrails 2.0 Update
Grails 2.0 Update
 
Scalable JavaScript
Scalable JavaScriptScalable JavaScript
Scalable JavaScript
 
Building Better Applications with Data::Manager
Building Better Applications with Data::ManagerBuilding Better Applications with Data::Manager
Building Better Applications with Data::Manager
 
The breakup
The breakupThe breakup
The breakup
 
CascadiaJS 2015 - Adding intelligence to your JS applications
CascadiaJS 2015 - Adding intelligence to your JS applicationsCascadiaJS 2015 - Adding intelligence to your JS applications
CascadiaJS 2015 - Adding intelligence to your JS applications
 
Why Our Code Smells
Why Our Code SmellsWhy Our Code Smells
Why Our Code Smells
 
Your Database Cannot Do this (well)
Your Database Cannot Do this (well)Your Database Cannot Do this (well)
Your Database Cannot Do this (well)
 
Pinterest的数据库分片架构
Pinterest的数据库分片架构Pinterest的数据库分片架构
Pinterest的数据库分片架构
 
The Breakup - Logically Sharding a Growing PostgreSQL Database
The Breakup - Logically Sharding a Growing PostgreSQL DatabaseThe Breakup - Logically Sharding a Growing PostgreSQL Database
The Breakup - Logically Sharding a Growing PostgreSQL Database
 
Jan Lehnardt Couch Db In A Real World Setting
Jan Lehnardt Couch Db In A Real World SettingJan Lehnardt Couch Db In A Real World Setting
Jan Lehnardt Couch Db In A Real World Setting
 
Postgres vs Mongo / Олег Бартунов (Postgres Professional)
Postgres vs Mongo / Олег Бартунов (Postgres Professional)Postgres vs Mongo / Олег Бартунов (Postgres Professional)
Postgres vs Mongo / Олег Бартунов (Postgres Professional)
 
Enterprise javascriptsession3
Enterprise javascriptsession3Enterprise javascriptsession3
Enterprise javascriptsession3
 
Spring data requery
Spring data requerySpring data requery
Spring data requery
 
Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)
 
SharePoint PnP Demo - react-display-hierarchy
SharePoint PnP Demo - react-display-hierarchySharePoint PnP Demo - react-display-hierarchy
SharePoint PnP Demo - react-display-hierarchy
 
Authorship attribution pydata london
Authorship attribution   pydata londonAuthorship attribution   pydata london
Authorship attribution pydata london
 
Kicking ass with redis
Kicking ass with redisKicking ass with redis
Kicking ass with redis
 
Scaling Databases with DBIx::Router
Scaling Databases with DBIx::RouterScaling Databases with DBIx::Router
Scaling Databases with DBIx::Router
 
Java scriptforjavadev part2a
Java scriptforjavadev part2aJava scriptforjavadev part2a
Java scriptforjavadev part2a
 
2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach
 

Mais de Yehor Nazarkin (6)

Flask, rest and data
Flask, rest and dataFlask, rest and data
Flask, rest and data
 
Inter-process data exchange in Python
Inter-process data exchange in PythonInter-process data exchange in Python
Inter-process data exchange in Python
 
Flask, гордость и предубеждение
Flask, гордость и предубеждениеFlask, гордость и предубеждение
Flask, гордость и предубеждение
 
Chaplin.js in real life
Chaplin.js in real lifeChaplin.js in real life
Chaplin.js in real life
 
обзор Python
обзор Pythonобзор Python
обзор Python
 
GAE - плюсы/минусы/подводные камни
GAE - плюсы/минусы/подводные камниGAE - плюсы/минусы/подводные камни
GAE - плюсы/минусы/подводные камни
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Rest in flask

  • 1. REST in Flask raising
  • 3.  service I am: Yehor Nazarkin Follow me: @nimnull Email me: nimnull@gmail.com Saturday, June 2, 12
  • 5.  pieces • Representative state transfer • Hypertext transfer protocol: ✓ URL endpoint as resource address ✓ Content-Type ✓ Status codes • The Web is REST Saturday, June 2, 12
  • 7.  pieces Web Front Mobile client API Backends Saturday, June 2, 12
  • 13.  of
  • 14.  stuff • I’m not a framework junkie • I want to customize, not rewrite • Clean codebase (20 python modules) • Aware of django.contrib.admin, django.form, etc. • Lack of ORM functionality ✓ I don’t like to write raw SQL ✓ I need composite keys ✓ I want to optimize for a DB backend (we are on PostgreSQL) Saturday, June 2, 12
  • 16.  we
  • 20.  of
  • 21.  stuff Because we can Saturday, June 2, 12
  • 25.  tier Trafaret http://pypi.python.org/pypi/trafaret import trafaret as t t.Dict({'first_name': t.String, 'last_name': t.String, 'phone': t.String, t.Key('role_id', optional=True): t.Int }).ignore_extra('*') Saturday, June 2, 12
  • 29.  tier Key subset: t.Dict({'first_name': t.String, te.KeysSubset('pass', 'confirm'): cmp_pwds}) def cmp_pwds(value): if value['pass'] != value['confirm']: return {'confirm': t.DataError(Doesn't match)} return {'pass': value['pass']} Saturday, June 2, 12
  • 33.  tier Type check: • Null, Bool, String, Int, Float, List, Dict • Atom, Email, URL, Enum, Callable • Converters, ignorance, excludes, optional keys @guard(a=String, b=Int, c=String) def guarded(a, b, c): return a, b, c Saturday, June 2, 12
  • 35.  we
  • 36.  did Based on Flask’s MethodView Extended with method-decorators Simple to attach Resource — for generic cases ModelResource — SQLA mapped classes Saturday, June 2, 12
  • 38.  we
  • 39.  did Inspired by • django-tastypie • flask-restless • rainbows and unicorns Saturday, June 2, 12
  • 41.  we
  • 42.  did In Practice @api_resource(account, 'sessions', {'id': None}) class SessionResource(Resource): validation = t.Dict({'email': t.Email}).allow_extra('*') @api_resource(account, 'addresses', {'id': int}) class AddressResource(ModelResource): validation = t.Dict({'city': t.String, 'street': t.String, 'type': t.String(regex=(bill|delivery))} ).allow_extra('*') model = Address def get_objects(self): ... def get_object(self): ... Saturday, June 2, 12
  • 44.  we
  • 45.  did Differences @api_resource(account, 'profiles', {'id': None}) class RoleResource(ModelResource): validation = ... decorators = [login_required, ] method_decorators = {'post': check_permission('is_superuser'), 'put': check_permission('is_superuser')} Saturday, June 2, 12
  • 47.  we
  • 48.  don’t To be done • Filtering (DSL?) • Caching • Throttling • Customizing field set for ModelResource Saturday, June 2, 12
  • 51.  not