安装

easy_install pyramid

异常情况:

安装的时候要求zope.interface 3.80以上

easy_install  zope.interface

 

hello world

 1 from paste.httpserver import serve
2 from pyramid.config import Configurator
3 from pyramid.response import Response
4 from pyramid.view import view_config
5
6 @view_config(name='hello',request_method='GET')
7 def hello(request):
8 return Response("Hello %(name)s!" % request.matchdict)
9
10 if __name__ == '__main__':
11 config = Configurator()
12 config.add_route('hello',"/hello/{name}")
13 config.add_view(hello,route_name='hello')
14 app = config.make_wsgi_app()
15 serve(app,host='0.0.0.0')

 

$ python hello.py
serving on 0.0.0.0:8080 view at http://127.0.0.1:8080

相关文章:

  • 2021-04-01
  • 2021-06-02
  • 2021-09-04
  • 2022-02-08
  • 2021-12-03
  • 2022-02-28
  • 2021-11-06
  • 2021-11-02
猜你喜欢
  • 2021-05-20
  • 2021-11-21
  • 2021-07-22
  • 2021-07-17
  • 2021-05-31
  • 2022-12-23
相关资源
相似解决方案