Web backends development using Python

Post on 16-Apr-2017

26.117 views 3 download

Transcript of Web backends development using Python

Web backends developmentusing PythonAyun Park

Ayun Parkiamparkayun@gmail.com / http://parkayun.kr /

https://github.com/Parkayun

2

add2paperhttp://www.add2paper.com / http://www.additpay.com

Korea No.1 Mobile media for college students.

3

4

5

122 universities

6

7

based on django

8

used flask

9

used tornado

10

tried aiohttp

11

django, flask, tornado and

aiohttp12

djangoMost popular Python web framework

Full stack web framework

13

Most popular

14

Full stackweb framework

15

= has almost everything

16

Full stackORM

Template Engine

Tests

And more...

17

ORM

18

ORM

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

ORMMySQL

PostgreSQL

Oracle

MSSQL (unofficial)

21

template engine

22

template enginea lot of useful builtin tags

intcomma

autoescape

linebreaks

also can make custom tags

23

testsbased on unittest

TestCase

TransactionTestCase

LiveServerTestCase

24

And more...django admin

useful middlewares

session management

protection against csrf attack

migration

And more... in djangoproject.com 25

= django has super productivity

26

In my case

27

I use django when need web

pages(html).28

django was born for web sites.

29

flaskVery popluar Python web framework in developers

Microframework

30

Very popular

31

Werkzeug

jinja2

useful extensions

Microframework

32

Werkzeug

33

= WSGI Utility Library

34

= HTTP Server using Python

(PEP333)35

= URL Route and Response

36

jinja2

37

= template engine

38

similar with django’s

39

Microframework

40

= has almost nothing

41

= has free

42

= useful extensions

43

SQLAlchemy (Flask-SQLAlchemy)ORM

Alembic (Flask-Alembic)Migration

Flask-Login

session management

py.test (pytest-flask), nosetest

tests

And more...

useful extensions

44

In my case

45

I use flask inanytime.

46

flask isa microframework.

47

tornadoWeb framework

Asynchronous network library

48

Web framework

49

similar with flask

50

= has template engine

51

also, similar withdjango’s

52

but, It hasn’tenough bulitin

tags.53

Asynchronousnetwork library

54

= tornado’s key feature

55

After, Python2

56

has asyncio

57

= has async features

58

But, tornado has that

since Python2.59

= has good performancesince Python2

60

= can code socketand more

61

= even as a container

62

In my case

63

I use tornado whenbuild websocketand use nosql.

64

Async is tornado’skey feature.

65

Not use asyncwith rdbms.

66

or as a wsgi container

67

aiohttpHTTP Client / Server for asyncio

68

HTTP Serverfor asyncio.

69

= HTTP Serverfor Python3.

70

= like a werkzeugin flask.

71

= URL Route and Response

72

In my case

73

I use aiohttp whenbuild websocket

or try experiment.74

There are someasync rdbms driver

for Python3.75

I just started web frameworkbased on aiohttp.

76

In githubParkayun/astrid

77

In Real World

78

Yes, Python is slow.

79

check transaction.

80

check file io.

81

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

82

use Cache(redis, memcached)

83

uWSGI > gunicorn

84

use gevent

85

use PyPy

86

normal stack

87

django / flask

88

uWSGI / gunicronnginx / apache

MySQL / PostgreSQL / Oracle / MSSQL

Cache(redis / memcached / rabbitmq)

reverse proxy

Thanks a lot!