More Related Content
PDF
PPTX
Robot Framework (のSelenium2Libraryのお話) PDF
PDF
Werkzeugを使ってみた #osakapy 2016/04 PDF
PPTX
Re: WebServer BenchMarking PDF
PPTX
What's hot
PDF
PPTX
PDF
Java による Web アプリケーションのプロトタイプのために最近使っている構成 PDF
MogileFS をバックエンドとしたPrivate S3の作り方 【後半】API 編 PPTX
PHP x AWS でスケーラブルなシステムをつくろう PDF
PDF
PDF
PDF
PDF
chat bot framework for Java8 PDF
PDF
Web Framework Benchmarksと Perl の現状報告会 YAPC::Asia Tokyo 2014 LT KEY
PPTX
PDF
Closure Compiler Updates for ES6 PDF
PPTX
PDF
Djangoフレームワークの紹介 OSC2015北海道 PDF
PDF
apachehereというPHPのBuiltin Serverっぽいやつをつくった Viewers also liked
PPTX
Entity framework + Linq 介紹 PPTX
PDF
PDF
Functional Tests Automation with Robot Framework PDF
ATDD Using Robot Framework PDF
PDF
利用 Appium + Robot Framework 實現跨平台 App 互動測試 PDF
PDF
PDF
PDF
RaspberryPiで日本の子供たちにプログラミングのパッションを伝えよう! PDF
Python入門 コードリーディング - PyConJP2016 PDF
Rails Girls Weekly - 初探前端網頁技術 JavaScript 3/3 PDF
PDF
Frontend django, Django Web 前端探索 PDF
PDF
JavaCro'14 - Test Automation using RobotFramework Libraries – Stojan Peshov PDF
4コマ漫画 Machine Learning 分析データを集めたかった話 PDF
Robot framework association intro PDF
Similar to Webフレームワークを作ってる話 #osakapy
PPT
PDF
【とらラボLT】go言語でのweb apiの作り方3選 PDF
PDF
OCamlでWebアプリケーションを作るn個の方法 PPTX
PDF
PDF
PPTX
PDF
PDF
PDF
PDF
ODP
PDF
PDF
WordBench京都12月、WordCampUSからのWP REST APIな話 PDF
ODP
PDF
Webフレームワークパネル(Django) at PyConJP 2012 PDF
Pythonによるwebアプリケーション入門 - Django編- PDF
More from Masashi Shibata
PDF
実践Djangoの読み方 - みんなのPython勉強会 #72 PDF
サイバーエージェントにおけるMLOpsに関する取り組み at PyDataTokyo 23 PDF
Djangoアプリのデプロイに関するプラクティス / Deploy django application PDF
Django REST Framework における API 実装プラクティス | PyCon JP 2018 PDF
Goptuna Distributed Bayesian Optimization Framework at Go Conference 2019 Autumn PDF
Golangにおける端末制御 リッチなターミナルUIの実現方法 PDF
Django の認証処理実装パターン / Django Authentication Patterns PDF
How to develop a rich terminal UI application PDF
DARTS: Differentiable Architecture Search at 社内論文読み会 PDF
RTMPのはなし - RTMP1.0の仕様とコンセプト / Concepts and Specification of RTMP PDF
PDF
システムコールトレーサーの動作原理と実装 (Writing system call tracer for Linux/x86) PDF
pandasによるデータ加工時の注意点やライブラリの話 PDF
Implementing sobol's quasirandom sequence generator PDF
Pythonistaのためのデータ分析入門 - C4K Meetup #3 PDF
CMA-ESサンプラーによるハイパーパラメータ最適化 at Optuna Meetup #1 PDF
MLOps Case Studies: Building fast, scalable, and high-accuracy ML systems at ... PDF
PDF
PythonとAutoML at PyConJP 2019 PDF
Introduction of PyCon JP 2015 at PyCon APAC/Taiwan 2015 Webフレームワークを作ってる話 #osakapy
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
WSGI v1.0.1 (PEP3333)
•2つの引数を持った呼び出し可能なオブジェクト
• 第2引数として渡されたオブジェクトにHTTPス
テータスコードと (header_name,
header_value) タプルのリストを渡す
• 返り値はバイト文字列を yield する iterableなオ
ブジェクト
https://www.python.org/dev/peps/pep-3333/
- 7.
WSGI v1.0.1 (PEP3333)
defapp(env, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return [b"Hello World"]
• 2つの引数を持った呼び出し可能なオブジェクト
https://www.python.org/dev/peps/pep-3333/
- 8.
WSGI v1.0.1 (PEP3333)
defapp(env, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return [b"Hello World"]
• 第2引数として渡されたオブジェクトの引数は
HTTPステータスコードと
(header_name, header_value) タプルのリスト
https://www.python.org/dev/peps/pep-3333/
- 9.
WSGI v1.0.1 (PEP3333)
defapp(env, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return [b"Hello World"]
• バイト文字列を yield する iterable を返さなければ
ならない
• 例えば、バイト文字列のリストを返すようにする
https://www.python.org/dev/peps/pep-3333/
- 10.
Hello World withgunicorn
$ gunicorn -w 1 main:app
[2016-04-15 10:17:00 +0900] [1873] [INFO] Starting gunicorn 19.4.5
[2016-04-15 10:17:00 +0900] [1873] [INFO] Listening at: http://127.0.0.1:8000 (1873)
[2016-04-15 10:17:00 +0900] [1873] [INFO] Using worker: sync
[2016-04-15 10:17:00 +0900] [1878] [INFO] Booting worker with pid: 1878
^C[2016-04-15 10:17:08 +0900] [1873] [INFO] Handling signal: int
[2016-04-15 10:17:08 +0900] [1878] [INFO] Worker exiting (pid: 1878)
[2016-04-15 10:17:08 +0900] [1873] [INFO] Shutting down: Master
def app(env, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return [b"Hello World"]
- 11.
Hello World withwsgiref
$ python main.py
127.0.0.1 - - [15/Apr/2016 10:24:21] "GET / HTTP/1.1" 200 11
127.0.0.1 - - [15/Apr/2016 10:24:21] "GET /favicon.ico HTTP/1.1" 200 11
def app(env, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return [b"Hello World"]
if __name__ == '__main__':
from wsgiref.simple_server import make_server
httpd = make_server('', 8080, app)
httpd.serve_forever()
- 12.
- 13.
- 14.
- 15.
a small andstatically-typed web framework
kobin
https://github.com/c-bata/kobin
- 16.
a small andstatically-typed web framework
kobin
https://github.com/c-bata/kobin
- 17.
Hello World
from kobinimport Kobin
app = Kobin()
@app.route('^/(?P<name>w*)$')
def hello(name: str):
return "Hello {}!!".format(name)
if __name__ == '__main__':
app.run()
• 日本語: https://kobin.readthedocs.org/ja/latest/
• English: https://kobin.readthedocs.org/en/latest/
- 18.
Hello World withJinja2
import os
from kobin import Kobin, template
app = Kobin()
@app.route('^/$')
def index():
return template('index')
• https://github.com/c-bata/kobin-example
• https://kobin.herokuapp.com/
- 19.
- 20.
Routing in Django
fromdjango.conf.urls import url
urlpatterns = [
url(r'^blog/page(?P<num>[0-9]+)/$', page),
]
def page(request, num="1"):
# Output the appropriate page of blog entries
...
https://docs.djangoproject.com/en/1.9/topics/http/urls/
• 引数が全て文字列
- 21.
Routing in Bottle
frombottle import route
@route('/object/<id:int>')
def callback(id):
assert isinstance(id, int)
http://bottlepy.org/docs/dev/tutorial.html#request-routing
• 独自DSL
• 型が分かるため、view関数には型変換したオブジェ
クトを渡すことができる
- 22.
- 23.
Routing in Kobin
fromkobin import Kobin
app = Kobin()
@app.route('^/years/(?P<year>d{4})$')
def casted_year( year: int ):
return 'A "year" argument is integer? : {}’
.format(isinstance(year, int))
https://github.com/c-bata/kobin/blob/master/example/hello_world.py
• 正規表現により自由度が高い
• Type Hintsの恩恵(IDE, mypy)をそのまま受けれる
- 24.
Ecosystem Threats toPython
• Pythonのエコシステムはその巨大さゆえに、バー
ジョンアップについていきづらい
• コミュニティとしてもPython3に移行していきたい
• Type Hintsを移行のきっかけに
PyCon APAC/Taiwan 2015: Keynote
- 25.
- 26.
- 27.
PEP333 と PEP3333
$python2.7
>>> b'hoge' + u'日本語'
u'hogeu65e5u672cu8a9e'
$ python3.5
>>> b'hoge' + u'日本語'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can't concat bytes to str
- 28.
PEP333 と PEP3333
•PEP333 (WSGI v1.0)
• Python2ではbytesとstrを結合出来たり…
• Python3で文字列の扱いが大きく変わった
• PEP3333 (WSGI v1.0.1)
• 後方互換は保ったまま、文字列の扱いを整備して
長年たまってたデファクトの修正案も取り込み
- 29.