Examples¶
twisted.web.client¶
getpage.py
- usetwisted.web.client.getPage
to download a web page.dlpage.py
- add callbacks totwisted.web.client.downloadPage
to display errors that occur when downloading a web page
XML-RPC¶
xmlrpc.py
XML-RPC server with several methods, including echoing, faulting, returning deferreds and failed deferredsxmlrpcclient.py
- usetwisted.web.xmlrpc.Proxy
to call remote XML-RPC methodsadvogato.py
- usetwisted.web.xmlrpc
to post a diary entry to advogato.org; requires an advogato account
Virtual hosts and proxies¶
proxy.py
- usetwisted.web.proxy.Proxy
to make the simplest proxylogging-proxy.py
- example of subclassing the core classes oftwisted.web.proxy
to log requests through a proxyreverse-proxy.py
- usetwisted.web.proxy.ReverseProxyResource
to make any HTTP request to the proxy port get applied to a specified websiterootscript.py
- example use oftwisted.web.vhost.NameVirtualHost
web.py
- an example of both using theprocessors
attribute to set how certain file types are treated and usingtwisted.web.vhost.VHostMonsterResource
to reverse proxy
.rpys and ResourceTemplate¶
hello.rpy.py
- usetwisted.web.static
to create a static resource to servefortune.rpy.py
- create a resource that returns the output of a process run on the serverlj.rpy.py
- usetwisted.web.microdom
,twisted.web.domhelpers
, and chained callbacks to extract and display parts of a livejournal user’s rss pagereport.rpy.py
- display various properties of a resource, including path, host, and portusers.rpy.py
- usetwisted.web.distrib
to publish user directories as for a “community web site”- simple.rtl- example use of
twisted.web.resource.ResourceTemplate
Miscellaneous¶
webguard.py
- pairingtwisted.web
withtwisted.cred
to guard resources against unauthenticated userssilly-web.py
- bare-bones distributed web setup with a master and slave usingtwisted.web.distrib
andtwisted.spread.pb
soap.py
- usetwisted.web.soap
to publish SOAP methods