Pylons/pyramid — Issue #369: Correction of Sample Application on About Page
Author: chris2fr
Created: 2011-12-06 07:29:39+00:00
State: open

The code listed on the "about" page [1] does not in fact work.

[1] http://www.pylonsproject.org/projects/pyramid/about

I believe the code in the About page to be deprecated. We should replace it with the content in the Documentation site. The documentation site uses Python Paste instead of WSGIREF.

Here is the code in the about page :

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)
server.serve_forever()

Here is the code in the documentation page :

from paste.httpserver import serve
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()
serve(app, host='0.0.0.0')