超概要。中身あまりないです。
Hello World
def app(environ, start_response): start_response('200 OK', [('Content-Type', 'text/plain')]) yield 'Hello World\n'
代表的なWSGI対応アプリケーション、フレームワーク
- Django
- Google App Engine
- Pylons
- TurboGears
- Trac
- Flask
- Zope3
- などなど
WSGIアプリケーションを直接動かせるWebサーバ
- ServletだとServlet Container(TomcatとかGlassFish)
代表的なWSGIサーバ
- wsgiref
- mod_wsgi
- Paste HTTP Server
- gunicorn
- passenger(mod_rails)
- など
http://pythonpaste.org/deploy/
WSGIアプリのための設定ファイルを扱うライブラリ
iniファイル形式でWSGIアプリケーションとWSGIサーバの設定を記述
[app:main] use = egg:memocurial [server:main] use = egg:Paste#http host = 127.0.0.1 port = 5000
WSGIアプリケーションとWSGIサーバのPasteDeploy対応が必要
entry_pointsを定義
[paste.app_factory] main = myapp:make_app
コードはこんな感じ
from flask import Flask app = Flask(__name__) @app.route('/') def index(): return 'hello' def make_app(global_conf, **app_conf): """WSGIアプリを返す""" return app if __name__ == '__main__': app.run()
http://pythonpaste.org/script/
もともとはPaste(WSGIのためのユーティリティ集)のコマンドラインツール
PasteDeployの設定を利用してWSGIアプリを起動可能
% paster serve production.ini
指定したWSGIアプリケーションが、指定したWSGIサーバを使って動く
お手軽
http://www.freia.jp/taka/blog/666
清水川Webで紹介されているラッパーを利用する
import os from paste.deploy import loadapp ini = os.path.join(os.path.dirname(__file__), 'wsgi.ini') application = loadapp('config:%s' % ini)
Table of Contents | t |
---|---|
Exposé | ESC |
Full screen slides | e |
Presenter View | p |
Source Files | s |
Slide Numbers | n |
Toggle screen blanking | b |
Show/hide slide context | c |
Notes | 2 |
Help | h |