pyramid setup(修改版)

pyramid setup
参考

http://docs.pylonsproject.org/en/latest/docs/pyramid.html

今天是2012-03-12
讲的都是安装好Python2.7,以及在ubuntu操作系统下面:
1.首先装Pyramid,
测试语句import setuptools,没有ImportError错误,ok。有错误,先装setuptools。下载ez_setup.py,然后执行语句python ez_setup.py。


2.然后装virtualenv,
用语句easy_install virtualenv

3.用virtualenv创建Virtual Python Environment,
virtualenv --no-site-packages env
这个语句会创建一个env文件夹,这是一个Virtual Python Environment


4.其次把Pyramid2.7装进Virtual Python Environment。
cd env
bin/easy_install pyramid

5.执行测试代码,如下helloworld.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()
  

/path/to/your/virtualenv/bin/python helloworld.py
用浏览器访问http://localhost:8080/hello/world ,ok


合乎自然而生生不息。。。
原文地址:https://www.cnblogs.com/samwu/p/2392269.html