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
Refactoring a web application with Python
PDF
Django at Scale
PDF
Building Scalable Web Apps
PDF
Django Good Practices
PDF
Software maintenance PyConUK 2016
PDF
обзор Python
PDF
Pitfalls of Continuous Deployment
PDF
Robust Python Write Clean And Maintainable Code 1st Edition Patrick Viafore
PDF
Python于Web 2.0网站的应用 - QCon Beijing 2010
PDF
Software maintenance PyConPL 2016
PDF
Brubeck: Overview
PDF
Pycon2017 instagram keynote
PDF
iPhone Python love affair
PDF
Django Restful Web Services Gaston C Hillar
PDF
Brubeck
PDF
a hands on guide to django
PDF
Web Development with Python and Django
PDF
PyFoursquare: Python Library for Foursquare
PDF
Effective Python 90 specific ways to write better Python Second Edition Brett...
PDF
Thinking hard about_python
Refactoring a web application with Python
Django at Scale
Building Scalable Web Apps
Django Good Practices
Software maintenance PyConUK 2016
обзор Python
Pitfalls of Continuous Deployment
Robust Python Write Clean And Maintainable Code 1st Edition Patrick Viafore
Python于Web 2.0网站的应用 - QCon Beijing 2010
Software maintenance PyConPL 2016
Brubeck: Overview
Pycon2017 instagram keynote
iPhone Python love affair
Django Restful Web Services Gaston C Hillar
Brubeck
a hands on guide to django
Web Development with Python and Django
PyFoursquare: Python Library for Foursquare
Effective Python 90 specific ways to write better Python Second Edition Brett...
Thinking hard about_python

Recently uploaded (20)

PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPT
Teaching material agriculture food technology
PDF
Encapsulation theory and applications.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Machine learning based COVID-19 study performance prediction
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
KodekX | Application Modernization Development
PPTX
Cloud computing and distributed systems.
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Building Integrated photovoltaic BIPV_UPV.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Teaching material agriculture food technology
Encapsulation theory and applications.pdf
Network Security Unit 5.pdf for BCA BBA.
Machine learning based COVID-19 study performance prediction
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
cuic standard and advanced reporting.pdf
Encapsulation_ Review paper, used for researhc scholars
Reach Out and Touch Someone: Haptics and Empathic Computing
The AUB Centre for AI in Media Proposal.docx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
KodekX | Application Modernization Development
Cloud computing and distributed systems.
20250228 LYD VKU AI Blended-Learning.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...

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