Steve Piercy
2017-07-04 d91e5d4d5d0165a7f7599c84c988b981b5fd0d2d
commit | author | age
c90471 1 from wsgiref.simple_server import make_server
PE 2 from pyramid.config import Configurator
3 from pyramid.response import Response
4
5
6 def hello_world(request):
1779c2 7     # Some parameters from a request such as /?name=lisa
c90471 8     url = request.url
PE 9     name = request.params.get('name', 'No Name Provided')
10
11     body = 'URL %s with name: %s' % (url, name)
12     return Response(
13         content_type="text/plain",
14         body=body
15     )
16
17
18 if __name__ == '__main__':
d91e5d 19     with Configurator() as config:
SP 20         config.add_route('hello', '/')
21         config.add_view(hello_world, route_name='hello')
22         app = config.make_wsgi_app()
c90471 23     server = make_server('0.0.0.0', 6543, app)
257ac0 24     server.serve_forever()