WSGI Werkzeug and The Challenges of Building A Python Web Framework
WSGI Werkzeug and The Challenges of Building A Python Web Framework
@igorgue
The Problems
A paradigm shift in web applications More JavaScript! (about 40% of our
code base)
My Goal
http://webmachine.basho.com/images/http-headersstatus-v3.png
WSGI
def
hello_world(environ,
start_response):
start_response('200
OK',
[('Content-Type',
'text/plain')])
return
["Hello,
World!"]
Use a Webserver!
mod_wsgi Gunicorn uWSGI
Gunicorn*
$
gunicorn
module:main_function_or_class Or in our example: $
gunicorn
hello_world:hello_world #
if
we
have
a
hello_world.py
module
* my personal favorite
Werkzeug
from
werkzeug.wrappers
import
Request,
Response def
hello_world(environ,
start_response):
request
=
Request(environ)
response
=
Response("Hello
{0}".format(request.args.get('name',
"World")))
return
response(environ,
start_response)
Routes
self.url_map
=
Map([
Rule('/',
endpoint='index'),
Rule('/<name>',
endpoint='dashboard'),
Rule('/<name>/info',
endpoint='contact_information') ])
Debugger Support
Debugger Shell
Deployment
<VirtualHost
*>
ServerName
browserstuff.dev
WSGIDaemonProcess
browserstuff
user=user1
group=group1
processes=2
threads=5
WSGIScriptAlias
/
/Users/igor/code/wsgi_werkzeug/ werkzeug/app.wsgi
<Directory
/Users/igor/code/wsgi_werkzeug/werkzeug/>
WSGIProcessGroup
browserstuff
WSGIApplicationGroup
%{GLOBAL}
Order
deny,allow
Allow
from
all
</Directory> </VirtualHost>
https://github.com/benoitc/gunicorn/blob/master/examples/supervisor.conf
Recap
WSGI isnt hard Werkzeug gives you a lot of the base Stuff that Django doesnt even have Make your dreams come true, and you
might be the next DHH
Thanks!
http://senzari.com were hiring!