diff options
| author | Steve Piercy <web@stevepiercy.com> | 2018-08-21 12:03:58 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-08-21 12:03:58 -0700 |
| commit | f1cea823ada61213be36007b888534558e215f86 (patch) | |
| tree | 8e034b1c1c70283d9fbffb4b273c4aecc9ee2547 /docs/narr/hellotraversal.py | |
| parent | 820a752645b460ea8009b07a75c752ab09c53dec (diff) | |
| parent | 4b84f6e97b321309544513b0697e8b378a57bafc (diff) | |
| download | pyramid-f1cea823ada61213be36007b888534558e215f86.tar.gz pyramid-f1cea823ada61213be36007b888534558e215f86.tar.bz2 pyramid-f1cea823ada61213be36007b888534558e215f86.zip | |
Merge pull request #3332 from stevepiercy/hello-world-synch
Synch Hello World app with canonical version on trypyramid.com and el…
Diffstat (limited to 'docs/narr/hellotraversal.py')
| -rw-r--r-- | docs/narr/hellotraversal.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/docs/narr/hellotraversal.py b/docs/narr/hellotraversal.py index 1ef7525e6..095c3ef76 100644 --- a/docs/narr/hellotraversal.py +++ b/docs/narr/hellotraversal.py @@ -2,21 +2,24 @@ from wsgiref.simple_server import make_server from pyramid.config import Configurator from pyramid.response import Response + class Resource(dict): pass + def get_root(request): return Resource({'a': Resource({'b': Resource({'c': Resource()})})}) + def hello_world_of_resources(context, request): output = "Here's a resource and its children: %s" % context return Response(output) + if __name__ == '__main__': - config = Configurator(root_factory=get_root) - config.add_view(hello_world_of_resources, context=Resource) - app = config.make_wsgi_app() - server = make_server('0.0.0.0', 8080, app) + with Configurator() as config: + config.set_root_factory(get_root) + config.add_view(hello_world_of_resources, context=Resource) + app = config.make_wsgi_app() + server = make_server('0.0.0.0', 6543, app) server.serve_forever() - - |
