Web Development with Python


The Presentation inside:

Slide 0

Web backends development using Python Ayun Park


Slide 1

Ayun Park [email protected] / http://parkayun.kr / https://github.com/Parkayun Prdouct Team Leader at add2paper 2


Slide 2

add2paper http://www.add2paper.com / http://www.additpay.com Korea No.1 Mobile media for college students. 3


Slide 3

4


Slide 4

122 universities 5


Slide 5

6


Slide 6

7


Slide 7

based on django 8


Slide 8

used flask 9


Slide 9

used tornado 10


Slide 10

tried aiohttp 11


Slide 11

django, flask, tornado and aiohttp 12


Slide 12

django ● Most popular Python web framework ● Full stack web framework 13


Slide 13

Most popular 14


Slide 14

Full stack web framework 15


Slide 15

= has almost everything 16


Slide 16

Full stack ● ● ● ● ORM Template Engine Tests And more... 17


Slide 17

ORM 18


Slide 18

ORM 19


Slide 19

ORM >>> Foo.objects.filter(bar__contains=’1’) SELECT "world_foo"."id", "world_foo"."bar", "world_foo"."created_at", "world_foo"."modified_at" FROM "world_foo" WHERE "world_foo"."bar" LIKE ‘%1%’ ESCAPE \'\\\' LIMIT 21 20


Slide 20

ORM ● ● ● ● MySQL PostgreSQL Oracle MSSQL (unofficial) 21


Slide 21

template engine 22


Slide 22

template engine ● a lot of useful builtin tags ○ ○ ○ intcomma autoescape linebreaks ● also can make custom tags 23


Slide 23

tests ● ● ● ● based on unittest TestCase TransactionTestCase LiveServerTestCase 24


Slide 24

And more... ● django admin ● useful middlewares ○ session management ■ protection against csrf attack ● migration ● And more... in djangoproject.com 25


Slide 25

= django has super productivity 26


Slide 26

In my case 27


Slide 27

I use django when need web pages(html). 28


Slide 28

django was born for web sites. 29


Slide 29

flask ● Very popluar Python web framework in developers ● Microframework 30


Slide 30

Very popular 31


Slide 31

Microframework ● Werkzeug ● jinja2 ● useful extensions 32


Slide 32

Werkzeug 33


Slide 33

= WSGI Utility Library 34


Slide 34

= HTTP Server using Python (PEP333) 35


Slide 35

= URL Route and Response 36


Slide 36

jinja2 37


Slide 37

= template engine 38


Slide 38

similar with django’s 39


Slide 39

Microframework 40


Slide 40

= has almost nothing 41


Slide 41

= has free 42


Slide 42

= useful extensions 43


Slide 43

useful extensions ● SQLAlchemy (Flask-SQLAlchemy) ○ ORM ● Alembic (Flask-Alembic) ○ Migration ● Flask-Login ○ session management ● py.test (pytest-flask), nosetest ○ tests ● And more... 44


Slide 44

In my case 45


Slide 45

I use flask in anytime. 46


Slide 46

flask is a microframework. 47


Slide 47

tornado ● Web framework ● Asynchronous network library 48


Slide 48

Web framework 49


Slide 49

similar with flask 50


Slide 50

= has template engine 51


Slide 51

also, similar with django’s 52


Slide 52

but, It hasn’t enough bulitin tags. 53


Slide 53

Asynchronous network library 54


Slide 54

= tornado’s key feature 55


Slide 55

After, Python2 56


Slide 56

has asyncio 57


Slide 57

= has async features 58


Slide 58

But, tornado has that since Python2. 59


Slide 59

= has good performance since Python2 60


Slide 60

= can code socket and more 61


Slide 61

= even as a container 62


Slide 62

In my case 63


Slide 63

I use tornado when build websocket and use nosql. 64


Slide 64

Async is tornado’s key feature. 65


Slide 65

Not use async with rdbms. 66


Slide 66

or as a wsgi container 67


Slide 67

aiohttp ● HTTP Client / Server for asyncio 68


Slide 68

HTTP Server for asyncio. 69


Slide 69

= HTTP Server for Python3. 70


Slide 70

= like a werkzeug in flask. 71


Slide 71

= URL Route and Response 72


Slide 72

In my case 73


Slide 73

I use aiohttp when build websocket or try experiment. 74


Slide 74

There are some async rdbms driver for Python3. 75


Slide 75

I just started web framework based on aiohttp. 76


Slide 76

In github Parkayun/astrid 77


Slide 77

In Real World 78


Slide 78

Yes, Python is slow. 79


Slide 79

check transaction. 80


Slide 80

check file io. 81


Slide 81

‘’.join((‘a’, ‘b’)) > ‘a’ + ‘b’ 82


Slide 82

use Cache (redis, memcached) 83


Slide 83

uWSGI > gunicorn 84


Slide 84

use gevent 85


Slide 85

use PyPy 86


Slide 86

normal stack 87


Slide 87

nginx / apache reverse proxy uWSGI / gunicron django / flask Cache (redis / memcached / rabbitmq) MySQL / PostgreSQL / Oracle / MSSQL 88


Slide 88

Thanks a lot!


Slide 89


×

HTML:





Ссылка: