トップ 一覧 ping 検索 ヘルプ RSS ログイン

Pyramidの変更点

  • 追加された行はこのように表示されます。
  • 削除された行はこのように表示されます。
!!!Pyramid
[Python][Django]

*http://docs.pylonsproject.jp/projects/pyramid-doc-ja/en/latest/index.html
!!!導入
* Python のパッケージ管理 setuptools を導入しておく
!!VirtualEnvを利用してPythonの仮想環境を作成
::インストール
 c:\easy_install virtualenv
::ワークスペースの作成
 c:\work\python>virtualenv --no-site-package env
 New python executable in env\Scripts\python.exe
 Installing setuptools................done.
 Installing pip...................done.
::仮想環境の実行
 c:\work\python\env>cd Scripts
 
 c:\work\python\env\Scripts>activate
 (env) c:\work\python\env\Scripts>
!!Pyramidのインストール
::ワークスペースに移動
 (env) c:\work\python\env\Scripts>cd ..

::Pyramidのインストール
 (env) c:\work\python\env>easy_install pyramid
 Searching for pyramid
 Reading http://pypi.python.org/simple/pyramid/
 Reading http://docs.pylonshq.com
                 :
!!Hello World
*c:\work\python\hello_world.py
 from wsgiref.simple_server import make_server
 from pyramid.config import Configurator
 from pyramid.response import Response
 
 
 def hello_world(request):
     return Response('Hello %(name)s!' % request.matchdict)
 
 if __name__ == '__main__':
     config = Configurator()
     config.add_route('hello', '/hello/{name}')
     config.add_view(hello_world, route_name='hello')
     app = config.make_wsgi_app()
     server = make_server('0.0.0.0', 8080, app)
     server.serve_forever()

!!実行
 (env) c:\work\python>python hello_world.py

*http://localhost:8080/hello/World
{{ref_image pyramid_01.jpg}}