From d36b566a83addddb80d221aa042b828268f185f2 Mon Sep 17 00:00:00 2001 From: Dylan Jay Date: Thu, 25 Aug 2011 13:05:52 +1000 Subject: use routes in firstapp as they are more familar to most and put hello world on the front page to make grab framework shoppers attention. --- docs/narr/helloworld.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 docs/narr/helloworld.py (limited to 'docs/narr/helloworld.py') diff --git a/docs/narr/helloworld.py b/docs/narr/helloworld.py new file mode 100644 index 000000000..23bb146df --- /dev/null +++ b/docs/narr/helloworld.py @@ -0,0 +1,12 @@ +from paste.httpserver import serve +from pyramid.configuration import Configurator + +def hello_world(request): + return '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') \ No newline at end of file -- cgit v1.2.3 From f7fe1d3b9b98663febad51bd6c09b5a7f7ea3e1f Mon Sep 17 00:00:00 2001 From: Dylan Jay Date: Thu, 25 Aug 2011 15:19:02 +1000 Subject: fix helloworld example --- docs/narr/helloworld.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs/narr/helloworld.py') diff --git a/docs/narr/helloworld.py b/docs/narr/helloworld.py index 23bb146df..ce0fcf955 100644 --- a/docs/narr/helloworld.py +++ b/docs/narr/helloworld.py @@ -7,6 +7,6 @@ def hello_world(request): if __name__ == '__main__': config = Configurator() config.add_route('hello', '/hello/{name}') - config.add_view(hello_world, route_name='hello') + config.add_view(hello_world, route_name='hello', renderer='string') app = config.make_wsgi_app() serve(app, host='0.0.0.0') \ No newline at end of file -- cgit v1.2.3 From d73be153fa9544f453510524f34d55a7602e0896 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 25 Aug 2011 02:23:51 -0400 Subject: use Response; fix text --- docs/narr/helloworld.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'docs/narr/helloworld.py') diff --git a/docs/narr/helloworld.py b/docs/narr/helloworld.py index ce0fcf955..92e16efbb 100644 --- a/docs/narr/helloworld.py +++ b/docs/narr/helloworld.py @@ -1,12 +1,13 @@ from paste.httpserver import serve from pyramid.configuration import Configurator +from pyramid.response import Response def hello_world(request): - return 'Hello %(name)s!' % request.matchdict + 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', renderer='string') + config.add_view(hello_world, route_name='hello') app = config.make_wsgi_app() - serve(app, host='0.0.0.0') \ No newline at end of file + serve(app, host='0.0.0.0') -- cgit v1.2.3 From a58ce000544cddb67e6404915145bf8017bbcf87 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 8 Sep 2011 15:03:38 -0400 Subject: configuration->config --- docs/narr/helloworld.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs/narr/helloworld.py') diff --git a/docs/narr/helloworld.py b/docs/narr/helloworld.py index 92e16efbb..5f121d48d 100644 --- a/docs/narr/helloworld.py +++ b/docs/narr/helloworld.py @@ -1,5 +1,5 @@ from paste.httpserver import serve -from pyramid.configuration import Configurator +from pyramid.config import Configurator from pyramid.response import Response def hello_world(request): -- cgit v1.2.3 From f8869cb0664506204b22aa791003a6d5f8ded58c Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 6 Oct 2011 03:22:35 -0400 Subject: remove stray references to Paste --- docs/narr/helloworld.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'docs/narr/helloworld.py') diff --git a/docs/narr/helloworld.py b/docs/narr/helloworld.py index 5f121d48d..93a403a13 100644 --- a/docs/narr/helloworld.py +++ b/docs/narr/helloworld.py @@ -1,4 +1,4 @@ -from paste.httpserver import serve +from wsgiref.simple_server import make_server from pyramid.config import Configurator from pyramid.response import Response @@ -10,4 +10,6 @@ if __name__ == '__main__': 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') + server = make_server('0.0.0.0', 8080) + server.serve_forever() + -- cgit v1.2.3 From 97b888f8f2b01df8b37cbeab229e171324012c0f Mon Sep 17 00:00:00 2001 From: Catalin Iacob Date: Tue, 29 Nov 2011 22:21:43 +0100 Subject: Fix helloworld example. It got broken in f8869cb0664506204b22aa791003a6d5f8ded58c when moving from Paste to wsgiref. --- docs/narr/helloworld.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs/narr/helloworld.py') diff --git a/docs/narr/helloworld.py b/docs/narr/helloworld.py index 93a403a13..7c26c8cdc 100644 --- a/docs/narr/helloworld.py +++ b/docs/narr/helloworld.py @@ -10,6 +10,6 @@ if __name__ == '__main__': 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 = make_server('0.0.0.0', 8080, app) server.serve_forever() -- cgit v1.2.3 From 4aeb44f1ea912c3c3611bc677f654602488fedb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Fidosz?= Date: Fri, 3 Aug 2012 22:56:49 +0200 Subject: fixed indentation in narr/helloworld.py --- docs/narr/helloworld.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'docs/narr/helloworld.py') diff --git a/docs/narr/helloworld.py b/docs/narr/helloworld.py index 7c26c8cdc..c01329af9 100644 --- a/docs/narr/helloworld.py +++ b/docs/narr/helloworld.py @@ -2,14 +2,15 @@ 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) + 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() + 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() -- cgit v1.2.3