Debian Codegraph @

docs/web/examples/silly-web.py

raw
1 # Copyright (c) Twisted Matrix Laboratories.
2 # See LICENSE for details.
3
4 """
5 This shows an example of a bare-bones distributed web set up. The "master" and
6 "slave" parts will usually be in different files -- they are here together only
7 for brevity of illustration. In normal usage they would each run in a separate
8 process.
9
10 Usage:
11 $ python silly-web.py
12
13 Then visit http://localhost:19988/.
14 """
15
16 from twisted.internet import reactor
17 from twisted.spread import pb
18 from twisted.web import distrib, server, static
19
20 # The "master" server
21 site = server.Site(distrib.ResourceSubscription("unix", ".rp"))
22 reactor.listenTCP(19988, site)
23
24 # The "slave" server
25 fact = pb.PBServerFactory(distrib.ResourcePublisher(server.Site(static.File("static"))))
26
27 reactor.listenUNIX("./.rp", fact)
28 reactor.run()