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

Python Webフレームワーク比較

Manabu TERADA
September 17, 2019

Python Webフレームワーク比較

Comparing Python Web Framework / PyCon JP 2019

発表者
寺田 学
(株)CMSコミュニケーションズ代表取締役 Python Web関係の業務を中心にコンサルティングや構築を手がけている。

発表詳細
このトークでは、以下の4つのパートに分けて説明をします。

Webフレームワークとは (フレームワークの定義)
Webフレームワークが持つ機能
Python Webフレームワークの種類と特徴を紹介と比較
目的別フレームワーク選択の方法

Manabu TERADA

September 17, 2019
Tweet

More Decks by Manabu TERADA

Other Decks in Technology

Transcript

  1. Comparing Python Web
    Framework
    Python Web
    Manabu TERADA (@terapyon)
    CMScom
    2019-09-17
    PyCon JP 2019 (Day 2)

    View full-size slide

  2. About me
    ✦ Owner and CEO of CMS communications Inc. (CMS )
    ✦ Board Chair of PyCon JP (Japan)
    ✦ Board of Python ED (Japan)
    ✦ Plone Foundation Ambassador
    ✦ PSF Contributing member
    ✦ Member of NVDA Japanese Team
    !2
    Manabu TERADA (@terapyon)

    View full-size slide

  3. About our company
    ✦ Our company is CMScom based in Tokyo, Japan
    ✦ We use Plone for building web sites
    ✦ Universities, Public institutions
    ✦ Engineering companies
    ✦ Supporting education tools
    !3
    CMScom (CMS )

    View full-size slide

  4. PyCon JP

    ✦ PyCon JP ( )
    ✦ Day 2 12:10 - 13:10 6 Room E
    ✦ PyCon JP
    ✦ 1
    !5
    PyCon JP

    View full-size slide

  5. Contents of this session
    What is a Web Framework and how do we design the
    framework
    (Web )
    List of functions for a Web Framework
    (Web )
    List of Web Frameworks and introduction of features
    for each framework
    (Web )
    How to choose a Web Framework for my project
    ( ?)
    !6

    View full-size slide

  6. History of
    Web Frameworks
    Web

    View full-size slide

  7. History of Web Frameworks
    ✦ Django
    ✦ Flask
    ✦ Pyramid
    ✦ Zope
    ✦ Tornado
    ✦ aiohttp
    ✦ Guillotina
    ✦ Bottle
    ✦ responder
    !8
    List of typical frameworks in this talk

    View full-size slide

  8. History of Web Frameworks
    !9
    List of typical frameworks in this talk
    2020
    2010 2015
    2005

    View full-size slide

  9. What is a Web
    Framework
    and how can we design a framework
    8FCϑϨʔϜϫʔΫͱ͸ʁ
    ϑϨʔϜϫʔΫΛͲ͏ఆٛ͢Δʁ

    View full-size slide

  10. What is a Web Framework
    ✦ Web Application Framework (Web )
    ✦ Sending HTML/JSON to browsers ( HTML/JSON )
    ✦ Support HTTP protocol (HTTP )
    ✦ GET / POST method
    ✦ Status code
    !11
    What? ( )

    View full-size slide

  11. What is a Web Framework
    ✦ Inspecting URL and nding form URL to the content
    ✦ (URL URL )
    ✦ Routing ( )
    ✦ traversal ( )
    ✦ Handling POST or GET (POST GET )
    ✦ HTML Templates (HTML )
    ✦ Database connection ( )
    ✦ sessions and cookies ( )
    !12
    to design the framework in this talk

    View full-size slide

  12. List of functions for a
    Web Framework
    8FCϑϨʔϜϫʔΫͷػೳҰཡ

    View full-size slide

  13. List of functions for a Web Framework
    important functions ( )
    ✦ HTML Template
    ✦ URL dispatcher
    ✦ Managing Requests
    ✦ Managing cookies
    ✦ Login function
    ✦ Managing users
    ✦ Persistent layer
    ✦ Type of Databases
    ✦ Manage data in a Database
    ✦ Web server
    ✦ Run command or manage daemon
    ✦ REST API
    ✦ Handling local data
    ✦ Async server
    ✦ Setting up and managing
    environment data
    !14

    View full-size slide

  14. List of functions for a Web Framework
    HTML Template ( )
    ✦ Building a HTML in dynamic
    ✦ ( HTML )
    ✦ Set to parts of some templates
    ✦ ( )
    ✦ Template inheritance
    ✦ ( )
    ✦ ltering or running tiny functions
    ✦ ( )
    ✦ control of loop and condition
    ✦ ( )
    ✦ List of Template engine
    ✦ DTE(Django Template Engine)
    ✦ jinja2
    ✦ mako
    ✦ Chameleon / ZPT
    !15

    View full-size slide

  15. List of functions for a Web Framework
    URL dispatcher
    ✦ Inspecting URL
    ✦ (URL )
    ✦ Routing
    ✦ ( )
    ✦ Finding the function or the content
    ✦ ( )
    ✦ Type of URL dispatcher
    ✦ Routing
    ✦ like url.py as Django
    ✦ decorator
    ✦ Object Traversal
    !16

    View full-size slide

  16. List of functions for a Web Framework
    ✦ Almost frameworks supported
    ✦ ( )
    ✦ but each frameworks are di erent approach
    ✦ ( )
    ✦ argument ( )
    ✦ global variable of local thread ( )
    !17
    Managing Requested Objects (Request )

    View full-size slide

  17. List of functions for a Web Framework
    ✦ Almost frameworks supported
    ✦ ( )
    ✦ Getting cookie from request object
    ✦ ( )
    ✦ Handling cookie to response object
    ✦ ( )
    !18
    Managing cookies (cookie )

    View full-size slide

  18. List of functions for a Web Framework
    ✦ some frameworks supported
    ✦ ( )
    ✦ some frameworks supported by ad-don
    ✦ ( )
    !19
    Login function ( )

    View full-size slide

  19. List of functions for a Web Framework
    ✦ some frameworks supported
    ✦ ( )
    ✦ some frameworks supported by ad-don
    ✦ ( )
    ✦ some frameworks does NOT support, Needing to make if you want
    ✦ ( )
    !20
    Managing users ( )

    View full-size slide

  20. List of functions for a Web Framework
    ✦ Type of Databases ( )
    ✦ Django ORM for RDBMS
    ✦ SQLAlchemy for RDBMS
    ✦ KVS
    ✦ Object DB
    ✦ Managing data in Database ( )
    ✦ Data management for record or content
    !21
    Persistent layer ( )

    View full-size slide

  21. List of functions for a Web Framework
    Web server
    ✦ Support WSGI
    ✦ Support ASGI
    ✦ Original
    ✦ WSGI Server
    ✦ gunicorn
    ✦ uWSGI
    ✦ Waitress
    ✦ ASGI Server
    ✦ Uvicorn
    !22

    View full-size slide

  22. List of functions for a Web Framework
    ✦ like run server (run )
    ✦ Manage demon prosess ( )
    !23
    Run command or manage daemon

    View full-size slide

  23. List of functions for a Web Framework
    ✦ for frontend and more
    ✦ RESTfull API
    ✦ some frameworks supported
    ✦ ( )
    ✦ some frameworks supported by ad-don
    ✦ ( )
    ✦ some frameworks does NOT support, Needing to make if you want
    ✦ ( )
    !24
    REST API

    View full-size slide

  24. List of functions for a Web Framework
    ✦ Support Async function
    ✦ (Async )
    ✦ some frameworks supported
    ✦ ( Async )
    !25
    Async server ( )

    View full-size slide

  25. List of functions for a Web Framework
    ✦ Install ( )
    ✦ pip
    ✦ buildout
    ✦ other
    ✦ environ setting ( )
    ✦ ini le
    ✦ python code
    ✦ yml
    !26
    Setting up and managing environment data
    ( )

    View full-size slide

  26. Web Frameworks
    8FCϑϨʔϜϫʔΫͷ঺հ

    View full-size slide

  27. Web Frameworks
    ✦ Django
    ✦ Flask
    ✦ Pyramid
    ✦ Zope
    ✦ Tornado
    ✦ aiohttp
    ✦ Guillotina
    ✦ Bottle
    ✦ responder
    !28
    List of typical frameworks in this talk

    View full-size slide

  28. Web Frameworks
    ✦ Django https://www.djangoproject.com/
    ✦ Django Software Foundation
    ✦ BSD license
    ✦ First release on PyPi 1.0.1 / May 18, 2010
    ✦ Recent update 2.1.4 in Jan 1, 2019
    ✦ Full stack all in one Web Framework
    ✦ ( Web )
    !29
    Django

    View full-size slide

  29. Web Frameworks
    Django for me
    ✦ Good point for me

    ✦ (Django admin)
    ✦ Bad point for me

    !30

    View full-size slide

  30. List of functions for a Web Framework
    Django has functions
    ✦ HTML Template
    ✦ URL dispatcher
    ✦ url.py
    ✦ Managing Requests
    ✦ Managing cookies
    ✦ Login function
    ✦ Managing users
    ✦ Persistent layer
    ✦ only ORM (Need a SQL server)
    ✦ Manage data in a Database
    ✦ Web server
    ✦ Test server
    ✦ Support WSGI
    ✦ Run command or manage daemon
    ✦ REST API (Add-on DRF)
    ✦ Handling local data
    ✦ Using request object
    ✦ Async server
    ✦ Setting up and managing
    environment data
    ✦ Python code
    !31

    View full-size slide

  31. Web Frameworks
    ✦ Flask http:// ask.pocoo.org/
    ✦ Pallets team (Armin Ronacher)
    ✦ BSD licensed
    ✦ First release on PyPi 0.1 / Apr 16, 2010
    ✦ Recent update 1.0.2 in Jan 1, 2019
    ✦ Simple and useful Web Framework
    ✦ ( Web )
    !32
    Flask

    View full-size slide

  32. Web Frameworks
    Flask for me
    ✦ Good point for me


    ✦ Bad point for me


    !33

    View full-size slide

  33. List of functions for a Web Framework
    important functions
    ✦ HTML Template
    ✦ URL dispatcher
    ✦ decorator
    ✦ Managing Requests
    ✦ Managing cookies
    ✦ Login function
    ✦ Managing users
    ✦ Persistent layer
    ✦ ORM (Add-on)
    ✦ Manage data in a Database
    ✦ Web server
    ✦ Test server
    ✦ Support WSGI
    ✦ Run command or manage daemon
    ✦ REST API (Add-on ask-restplus)
    ✦ Handling local data
    ✦ global variable
    ✦ Async server
    ✦ Setting up and managing
    environment data
    ✦ Python code or ini le
    !34

    View full-size slide

  34. Web Frameworks
    ✦ Pyramid https://trypyramid.com/
    ✦ Pylons Project
    ✦ Repoze Public License (BSD-like)
    ✦ First release on PyPi 1.0 / Jan 31, 2011
    ✦ Recent update 1.10.1 in Jan 1, 2019
    ✦ Full support Web Framework
    ✦ Web
    !35
    Pyramid

    View full-size slide

  35. Web Frameworks
    Pyramid for me
    ✦ Good point for me


    ✦ Bad point for me

    !36

    View full-size slide

  36. List of functions for a Web Framework
    important functions
    ✦ HTML Template
    ✦ Add-on (choosing any template)
    ✦ URL dispatcher
    ✦ decorator
    ✦ traversal
    ✦ Managing Requests
    ✦ Managing cookies
    ✦ Login function
    ✦ Managing users
    ✦ Persistent layer
    ✦ ORM or ZODB
    ✦ Manage data in a Database
    ✦ Web server
    ✦ Test server
    ✦ Support WSGI
    ✦ Run command or manage daemon
    ✦ REST API
    ✦ Need to make a code
    ✦ Handling local data
    ✦ context object
    ✦ Async server
    ✦ a part of support
    ✦ Setting up and managing
    environment data
    ✦ ini le
    !37

    View full-size slide

  37. Web Frameworks
    ✦ Zope2 / Zope http://www.zope.org/
    ✦ Zope Foundation (Plone Foundation)
    ✦ Zope Public License
    ✦ First release before 2000
    ✦ Recent update 2.13.28 / 4.0a in Jan 1, 2019
    ✦ Full stack biggest Web Framework
    ✦ Web
    !38
    Zope

    View full-size slide

  38. Web Frameworks
    Zope for me
    ✦ Good point for me


    ✦ Bad point for me

    !39

    View full-size slide

  39. List of functions for a Web Framework
    important functions
    ✦ HTML Template
    ✦ URL dispatcher
    ✦ object traversal
    ✦ Managing Requests
    ✦ Managing cookies
    ✦ Login function
    ✦ Managing users
    ✦ Persistent layer
    ✦ Include a Object DB (ZODB)
    ✦ Manage data in a Database
    ✦ Web server
    ✦ Original or WSGI
    ✦ Run command or manage daemon
    ✦ REST API
    ✦ Add-on
    ✦ Handling local data
    ✦ context object
    ✦ Async server
    ✦ Setting up and managing
    environment data
    ✦ Conf le by buildout
    !40

    View full-size slide

  40. Web Frameworks
    ✦ Tornado https://www.tornadoweb.org
    ✦ Facebook (originally developed at FriendFeed)
    ✦ Apache License, Version 2.0
    ✦ First release on PyPi 0.2 / May 18, 2010
    ✦ Recent update 5.1.1 in Jan 1, 2019 (now 6.0 already released)
    ✦ Asynchronous Web Framework
    ✦ ( Web )
    !41
    Tornado

    View full-size slide

  41. Web Frameworks
    Tornado for me
    ✦ Good point for me

    ✦ Bad point for me

    !42

    View full-size slide

  42. List of functions for a Web Framework
    important functions
    ✦ HTML Template
    ✦ Original
    ✦ URL dispatcher
    ✦ Register
    ✦ Managing Requests
    ✦ Managing cookies
    ✦ Login function
    ✦ Managing users
    ✦ Persistent layer
    ✦ Type of Databases
    ✦ Manage data in a Database
    ✦ Web server
    ✦ Original
    ✦ Run command or manage daemon
    ✦ REST API
    ✦ Need to make a code
    ✦ Handling local data
    ✦ Async server
    ✦ Setting up and managing
    environment data
    ✦ tornado.options (parse_*)
    !43

    View full-size slide

  43. Web Frameworks
    ✦ aiohttp https://aiohttp.readthedocs.io/
    ✦ Nikolay Kim and Andrew Svetlov
    ✦ Apache 2 licensed
    ✦ First release on PyPi 0.1 / Oct 26, 2013
    ✦ Recent update 3.5.1 in Jan 1, 2019
    ✦ Async HTTP client/server for asyncio
    ✦ ( HTTP )
    !44
    aiohttp

    View full-size slide

  44. Web Frameworks
    aiohttp for me
    ✦ Good point for me

    ✦ Bad point for me

    !45

    View full-size slide

  45. List of functions for a Web Framework
    important functions
    ✦ HTML Template
    ✦ add-on (aiohttp_jinja2)
    ✦ URL dispatcher
    ✦ Register
    ✦ decorator
    ✦ Managing Requests
    ✦ Managing cookies
    ✦ Login function
    ✦ add-on (aiohttp_session)
    ✦ Managing users
    ✦ Persistent layer
    ✦ Type of Databases
    ✦ Manage data in a Database
    ✦ (aiopg.sa)
    ✦ Web server
    ✦ Original
    ✦ Run command or manage daemon
    ✦ REST API
    ✦ Need to make a code
    ✦ Handling local data
    ✦ app object in request
    ✦ Async server
    ✦ Setting up and managing
    environment data
    !46

    View full-size slide

  46. Web Frameworks
    ✦ Guillotina https://guillotina.readthedocs.io
    ✦ Ramon Navarro Bosch & Nathan Van Gheem (Plone Foundation)
    ✦ BSD license
    ✦ First release on PyPi 1.3.0 / Aug 1, 2017
    ✦ Recent update 4.4.0 in Jan 1, 2019
    ✦ AsyncIO REST API Framework for Object model
    ✦ ( REST API )
    !47
    Guillotina

    View full-size slide

  47. Web Frameworks
    Guillotina for me
    ✦ Good point for me


    ✦ Bad point for me


    !48

    View full-size slide

  48. List of functions for a Web Framework
    important functions
    ✦ HTML Template
    ✦ URL dispatcher
    ✦ object traversal
    ✦ Managing Requests
    ✦ Managing cookies
    ✦ Login function
    ✦ Managing users
    ✦ Persistent layer
    ✦ Special connector to PostgreSQL
    ✦ Manage data in a Database
    ✦ Web server
    ✦ Run command or manage daemon
    ✦ REST API
    ✦ Handling local data
    ✦ context
    ✦ Async server
    ✦ Setting up and managing
    environment data
    ✦ yaml
    !49

    View full-size slide

  49. Web Frameworks
    ✦ Bottle https://bottlepy.org/
    ✦ Marcel Hellkamp
    ✦ MIT License
    ✦ First release on PyPi 0.4.3 / Jul 7, 2009
    ✦ Recent update 0.12.16 in Jan 1, 2019
    ✦ Simple and lightweight WSGI micro web-framework
    ✦ ( )
    !50
    Bottle

    View full-size slide

  50. Web Frameworks
    Bottle for me
    ✦ Good point for me

    ✦ Bad point for me

    !51

    View full-size slide

  51. List of functions for a Web Framework
    important functions
    ✦ HTML Template
    ✦ Add-on (choosing any template)
    ✦ URL dispatcher
    ✦ decorator
    ✦ Managing Requests
    ✦ Managing cookies
    ✦ Login function
    ✦ Managing users
    ✦ Persistent layer
    ✦ ORM (add-on)
    ✦ Manage data in a Database
    ✦ Web server
    ✦ Test server
    ✦ Support WSGI
    ✦ Run command or manage daemon
    ✦ REST API
    ✦ Need to make a code
    ✦ Handling local data
    ✦ Async server
    ✦ Setting up and managing
    environment data
    !52

    View full-size slide

  52. Web Frameworks
    ✦ responder https://python-responder.org/
    ✦ Kenneth Reitz
    ✦ Apache License, Version 2.0
    ✦ First release on PyPi 0.0.0 / Oct 9, 2018
    ✦ Recent update 1.1.2 in Jan 1, 2019 (now 1.3 already released)
    ✦ ASGI app for API server
    ✦ (ASGI API )
    !53
    responder

    View full-size slide

  53. Web Frameworks
    responder for me
    ✦ Good point for me

    ✦ Bad point for me
    ✦ ( ??)
    !54

    View full-size slide

  54. List of functions for a Web Framework
    important functions
    ✦ HTML Template
    ✦ jinja2
    ✦ URL dispatcher
    ✦ decorator
    ✦ Managing Requests
    ✦ Managing cookies
    ✦ Login function
    ✦ Managing users
    ✦ Persistent layer
    ✦ Type of Databases
    ✦ Manage data in a Database
    ✦ Web server
    ✦ ASGI??
    ✦ Run command or manage daemon
    ✦ REST API
    ✦ Handling local data
    ✦ ??
    ✦ Async server
    ✦ Setting up and managing
    environment data
    ✦ ??
    !55

    View full-size slide

  55. Web Frameworks
    ✦ Starlette
    ✦ https://www.starlette.io/
    ✦ ASGI app for API server
    ✦ (ASGI API )
    !56
    One more

    View full-size slide

  56. How to choose
    a Web Framework
    for my project
    ϓϩδΣΫτͰͲͷΑ͏ʹϑϨʔϜϫʔΫΛબͿ͔
    ࢲͷ৔߹

    View full-size slide

  57. How to choose a Web Framework for your project
    News site ( )






    !58
    ✦ Django
    ✦ Flask
    ✦ Pyramid
    ✦ Zope
    ✦ Tornado
    ✦ aiohttp
    ✦ Guillotina
    ✦ Bottle
    ✦ responder

    View full-size slide

  58. How to choose a Web Framework for your project
    API backend server (API )
    ✦ JSON


    ✦ ?

    !59
    ✦ Django
    ✦ Flask
    ✦ Pyramid
    ✦ Zope
    ✦ Tornado
    ✦ aiohttp
    ✦ Guillotina
    ✦ Bottle
    ✦ responder

    View full-size slide

  59. How to choose a Web Framework for your project
    Single endpoint API server (1 API)
    ✦ JSON


    ✦ ?
    ✦ AWS Lambda ?
    !60
    ✦ Django
    ✦ Flask
    ✦ Pyramid
    ✦ Zope
    ✦ Tornado
    ✦ aiohttp
    ✦ Guillotina
    ✦ Bottle
    ✦ responder

    View full-size slide

  60. How to choose a Web Framework for your project
    Portal site ( )





    !61
    ✦ Django
    ✦ Flask
    ✦ Pyramid
    ✦ Zope
    ✦ Tornado
    ✦ aiohttp
    ✦ Guillotina
    ✦ Bottle
    ✦ responder

    View full-size slide

  61. How to choose a Web Framework for your project
    CMS ( )







    !62
    ✦ Django
    ✦ Flask
    ✦ Pyramid
    ✦ Zope
    ✦ Tornado
    ✦ aiohttp
    ✦ Guillotina
    ✦ Bottle
    ✦ responder

    View full-size slide

  62. How to choose a Web Framework for your project
    API Server for CMS
    ✦ JSON







    !63
    ✦ Django
    ✦ Flask
    ✦ Pyramid
    ✦ Zope
    ✦ Tornado
    ✦ aiohttp
    ✦ Guillotina
    ✦ Bottle
    ✦ responder

    View full-size slide

  63. Q A
    ࣭ٙԠ౴

    View full-size slide

  64. Special thanks go to
    review this document
    !BPEBH
    !D@CBUB@
    !PKJJEPUDI

    View full-size slide

  65. Thank you!
    !UFSBQZPO
    UFSBEB!DNTDPNKQ

    View full-size slide