Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A python web service

Vlad Temian
November 12, 2013

A python web service

How to build an API in python? A comparison between Django, Django REST Framework, Django Tastypie and Flask

Vlad Temian

November 12, 2013
Tweet

More Decks by Vlad Temian

Other Decks in Technology

Transcript

  1. A Python a web service Tools & Utilities management tools

    supporting services Web Process Worker Process WEB APPLICATION
  2. A Python a web service Tools & Utilities management tools

    supporting services Web Process user interface api service data persistence auth crud admin Worker Process WEB APPLICATION
  3. A Python a web service Tools & Utilities management tools

    supporting services Web Process user interface api service data persistence auth crud admin Worker Process deferred tasks scheduled tasks WEB APPLICATION
  4. A Python a web service Tools & Utilities management tools

    supporting services Web Process user interface api service data persistence auth crud admin Worker Process deferred tasks scheduled tasks WEB APPLICATION
  5. A Python a web service Tools & Utilities management tools

    supporting services Web Process user interface api service data persistence auth crud admin Worker Process deferred tasks scheduled tasks WEB APPLICATION
  6. A Python a web service Tools & Utilities management tools

    supporting services Web Process user interface api service data persistence auth crud admin Worker Process deferred tasks scheduled tasks WEB APPLICATION
  7. A Python a web service Tools & Utilities management tools

    supporting services Web Process user interface api service data persistence auth crud admin Worker Process deferred tasks scheduled tasks WEB APPLICATION
  8. A Python a web service WEB APPLICATION Tools & Utilities

    management tools supporting services Web Process user interface api service data persistence auth crud admin Worker Process deferred tasks scheduled tasks TOTAL MESS
  9. A Python a web service Developers End Users Internal API

    service API service API service Data persistence
  10. A Python a web service Good API Intuitive similar things

    should be similar, ugly things should look ugly Documented Opinionated
  11. A Python a web service Features pagination propper HTTP response

    handling throttling permissions serialization authentification posting of data with validation
  12. A Python a web service regex routing system auth migrations

    management tools makes decision for you templating system built-in orm crud admin testing tools Django
  13. A Python a web service Developers End Users Internal API

    service API service API service Data persistence Django
  14. A Python a web service regex routing system makes decision

    for you templating system testing tools Django
  15. A Python a web service class ParentResource(ModelResource): children = fields.ToManyField(ChildResource,

    ‘children’) def prepend_urls(self): return [ url(r”^(?P<resource_name>%s)/(?P<pk>\w[\w/-]*)/children%s$” % (self._meta.resource_name, trailing_ slash()), self.wrap_view(‘get_children’), name=”api_get_children”), ] def get_children(self, request, **kwargs): try: bundle = self.build_bundle(data={‘pk’: kwargs[‘pk’]}, request=request) obj = self.cached_obj_get(bundle=bundle, **self.remove_api_resource_names(kwargs)) except ObjectDoesNotExist: return HttpGone() except MultipleObjectsReturned: return HttpMultipleChoices(“More than one resource is found at this URI.”) child_resource = ChildResource() return child_resource.get_detail(request, parent_id=obj.pk)
  16. A Python a web service Can do a lot of

    black magic A Python a web service Can do a lot of black magic
  17. A Python a web service from flask import Flask app

    = Flask(__name__) @app.route(“/”) def hello(): return “Hello World!” if __name__ == “__main__”: app.run()
  18. A Python a web service Some batteries Flask-SQLAlchemy Flask-Testing Flask-Oauthlib

    Flask-Script Flask-Principal Flask-Cache Flask-Classy
  19. A Python a web service Resources Kenneth Reitz Flask Goodness

    API Driven Development How I develop Things and Why? Kevin Lacker How to Design Great APIs?