SlideShare a Scribd company logo
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

More Related Content

PDF
BUILDING MODERN PYTHON WEB FRAMEWORKS USING FLASK WITH NEIL GREY
PPTX
Flask restfulservices
PDF
Python RESTful webservices with Python: Flask and Django solutions
PDF
How to Design a Great API (using flask) [ploneconf2017]
PDF
Lean React - Patterns for High Performance [ploneconf2017]
PDF
Flask - Backend com Python - Semcomp 18
PDF
Rest api with Python
PDF
Djangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 Minutes
BUILDING MODERN PYTHON WEB FRAMEWORKS USING FLASK WITH NEIL GREY
Flask restfulservices
Python RESTful webservices with Python: Flask and Django solutions
How to Design a Great API (using flask) [ploneconf2017]
Lean React - Patterns for High Performance [ploneconf2017]
Flask - Backend com Python - Semcomp 18
Rest api with Python
Djangocon 2014 - Django REST Framework - So Easy You Can Learn it in 25 Minutes

What's hot (20)

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

Viewers also liked (20)

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

Similar to Rest in flask (20)

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

More from Yehor Nazarkin (6)

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

Recently uploaded (20)

PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Advanced IT Governance
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
NewMind AI Monthly Chronicles - July 2025
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
KodekX | Application Modernization Development
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Empathic Computing: Creating Shared Understanding
PPT
Teaching material agriculture food technology
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Advanced methodologies resolving dimensionality complications for autism neur...
Advanced IT Governance
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Diabetes mellitus diagnosis method based random forest with bat algorithm
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
CIFDAQ's Market Insight: SEC Turns Pro Crypto
NewMind AI Monthly Chronicles - July 2025
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
KodekX | Application Modernization Development
Mobile App Security Testing_ A Comprehensive Guide.pdf
Chapter 3 Spatial Domain Image Processing.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
MYSQL Presentation for SQL database connectivity
20250228 LYD VKU AI Blended-Learning.pptx
Empathic Computing: Creating Shared Understanding
Teaching material agriculture food technology

Rest in flask

  • 1. REST in Flask raising
  • 3.  service I am: Yehor Nazarkin Follow me: @nimnull Email me: [email protected] 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