summaryrefslogtreecommitdiff
path: root/docs/narr/helloworld.py
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2017-07-12 20:06:48 -0500
committerGitHub <noreply@github.com>2017-07-12 20:06:48 -0500
commitd45f41f7423ef9064b827ef4d4d72bd41fd875f9 (patch)
treeb348ca6562eb1c80ea1baacdc0481ee6e95731b7 /docs/narr/helloworld.py
parentb8658e94f00962a78e3f8a4c97dd4fbc9e440a31 (diff)
parent0958d268b4b5451c615e05b2b4657d2afb5a7cd4 (diff)
downloadpyramid-d45f41f7423ef9064b827ef4d4d72bd41fd875f9.tar.gz
pyramid-d45f41f7423ef9064b827ef4d4d72bd41fd875f9.tar.bz2
pyramid-d45f41f7423ef9064b827ef4d4d72bd41fd875f9.zip
Merge pull request #3119 from stevepiercy/docs-context-manager
Update docs to use a Configurator context manager
Diffstat (limited to 'docs/narr/helloworld.py')
-rw-r--r--docs/narr/helloworld.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/docs/narr/helloworld.py b/docs/narr/helloworld.py
index c01329af9..29ed8e6f2 100644
--- a/docs/narr/helloworld.py
+++ b/docs/narr/helloworld.py
@@ -7,10 +7,9 @@ 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()
+ with Configurator() as config:
+ 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()
-