Ticket #317: server-317.py

File server-317.py, 0.7 KB (added by thijs, 4 months ago)
Line 
1import logging
2logging.basicConfig(level=logging.DEBUG,
3           format='%(asctime)s %(levelname)-5.5s [%(name)s] %(message)s')
4
5def echo(data):
6    """
7    Just return data back to the client.
8    """
9    return data
10
11services = {
12    'echo': echo,
13    'echo.echo': echo
14}
15
16if __name__ == '__main__':
17    from pyamf.remoting.gateway.wsgi import WSGIGateway
18    from wsgiref import simple_server
19
20    gw = WSGIGateway(services)
21
22    httpd = simple_server.WSGIServer(
23        ('localhost', 8000),
24        simple_server.WSGIRequestHandler,
25    )
26
27    httpd.set_app(gw)
28
29    print "Running AMF gateway on http://localhost:8000"
30
31    try:
32        httpd.serve_forever()
33    except KeyboardInterrupt:
34        pass