Slide 1

Slide 1 text

Comparing Python Web Framework Python Web Manabu TERADA (@terapyon) CMScom / Python ED 2019-05-18 PyCon Kyushu in Okinawa 2019

Slide 2

Slide 2 text

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)

Slide 3

Slide 3 text

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 )

Slide 4

Slide 4 text

About our company ✦ https://www.pythonic-exam.com/ ✦ Python ✦ ✦ ( ) ✦ !4 Python ED ( Python )

Slide 5

Slide 5 text

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 your project ( ?) !5

Slide 6

Slide 6 text

History of Web Frameworks Web

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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 !10 What? ( )

Slide 11

Slide 11 text

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 ( ) !11 to design the framework in this talk

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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 !13

Slide 14

Slide 14 text

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 !14

Slide 15

Slide 15 text

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 !15

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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 ✦ ( ) !19 Managing users ( )

Slide 20

Slide 20 text

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 !20 Persistent layer ( )

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

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 ✦ ( ) !23 REST API

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

Web Frameworks Django for me ✦ Good point for me ✦ ✦ (Django admin) ✦ Bad point for me ✦ !29

Slide 30

Slide 30 text

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 !30

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

Web Frameworks Flask for me ✦ Good point for me ✦ ✦ ✦ Bad point for me ✦ ✦ !32

Slide 33

Slide 33 text

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 !33

Slide 34

Slide 34 text

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

Slide 35

Slide 35 text

Web Frameworks Pyramid for me ✦ Good point for me ✦ ✦ ✦ Bad point for me ✦ !35

Slide 36

Slide 36 text

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 !36

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

Web Frameworks Zope for me ✦ Good point for me ✦ ✦ ✦ Bad point for me ✦ !38

Slide 39

Slide 39 text

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 !39

Slide 40

Slide 40 text

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 ✦ Lasted release 5.1.1 in Jan 1, 2019 (now 6.0 already released) ✦ Asynchronous Web Framework ✦ ( Web ) !40 Tornado

Slide 41

Slide 41 text

Web Frameworks Tornado for me ✦ Good point for me ✦ ✦ Bad point for me ✦ !41

Slide 42

Slide 42 text

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 ✦ ?? !42

Slide 43

Slide 43 text

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

Slide 44

Slide 44 text

Web Frameworks aiohttp for me ✦ Good point for me ✦ ✦ Bad point for me ✦ !44

Slide 45

Slide 45 text

List of functions for a Web Framework important functions ✦ HTML Template ✦ URL dispatcher ✦ Register ✦ decorator ✦ 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 !45

Slide 46

Slide 46 text

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 ✦ Lasted release 4.4.0 in Jan 1, 2019 ✦ AsyncIO REST API Framework for Object model ✦ ( REST API ) !46 Guillotina

Slide 47

Slide 47 text

Web Frameworks Guillotina for me ✦ Good point for me ✦ ✦ ✦ Bad point for me ✦ ✦ !47

Slide 48

Slide 48 text

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 !48

Slide 49

Slide 49 text

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

Slide 50

Slide 50 text

Web Frameworks Bottle for me ✦ Good point for me ✦ ✦ Bad point for me ✦ !50

Slide 51

Slide 51 text

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 !51

Slide 52

Slide 52 text

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

Slide 53

Slide 53 text

Web Frameworks responder for me ✦ Good point for me ✦ ✦ Bad point for me ✦ ( ??) !53

Slide 54

Slide 54 text

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 ✦ ?? !54

Slide 55

Slide 55 text

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

Slide 56

Slide 56 text

How to choose a Web Framework for your project News site ( ) ✦ ✦ ✦ ✦ ✦ ✦ !56 ✦ Django ✦ Flask ✦ Pyramid ✦ Zope ✦ Tornado ✦ aiohttp ✦ Guillotina ✦ Bottle ✦ responder

Slide 57

Slide 57 text

How to choose a Web Framework for your project API backend server (API ) ✦ JSON ✦ ✦ ✦ ? ✦ !57 ✦ Django ✦ Flask ✦ Pyramid ✦ Zope ✦ Tornado ✦ aiohttp ✦ Guillotina ✦ Bottle ✦ responder

Slide 58

Slide 58 text

How to choose a Web Framework for your project Single endpoint API server (1 API) ✦ JSON ✦ ✦ ✦ ? ✦ AWS Lambda ? !58 ✦ Django ✦ Flask ✦ Pyramid ✦ Zope ✦ Tornado ✦ aiohttp ✦ Guillotina ✦ Bottle ✦ responder

Slide 59

Slide 59 text

How to choose a Web Framework for your project Portal site ( ) ✦ ✦ ✦ ✦ ✦ !59 ✦ Django ✦ Flask ✦ Pyramid ✦ Zope ✦ Tornado ✦ aiohttp ✦ Guillotina ✦ Bottle ✦ responder

Slide 60

Slide 60 text

How to choose a Web Framework for your project CMS ( ) ✦ ✦ ✦ ✦ ✦ ✦ ✦ !60 ✦ Django ✦ Flask ✦ Pyramid ✦ Zope ✦ Tornado ✦ aiohttp ✦ Guillotina ✦ Bottle ✦ responder

Slide 61

Slide 61 text

How to choose a Web Framework for your project API Server for CMS ✦ JSON ✦ ✦ ✦ ✦ ✦ ✦ ✦ !61 ✦ Django ✦ Flask ✦ Pyramid ✦ Zope ✦ Tornado ✦ aiohttp ✦ Guillotina ✦ Bottle ✦ responder

Slide 62

Slide 62 text

Q A ࣭ٙԠ౴

Slide 63

Slide 63 text

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

Slide 64

Slide 64 text

Thank you! !UFSBQZPO UFSBEB!DNTDPNKQ