Imported Upstream version 12.1.0
[contrib/python-twisted.git] / doc / web / examples / silly-web.py
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, protocol
17 from twisted.web import server, distrib, static
18 from twisted.spread import pb
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()