Examples¶
twisted.web.client¶
httpclient.py
- usetwisted.web.client.Agent
to download a web page.(deprecated)
getpage.py
- usetwisted.web.client.getPage
to download a web page.(deprecated)
dlpage.py
- add callbacks totwisted.web.client.downloadPage
to display errors that occur when downloading a web page
XML-RPC¶
xmlrpcserver.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 methodsxmlrpc-debug.py
- usexmlrpc.Proxy
’squeryFactory
to debug raw XML-RPC trafficadvogato.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
- usetwisted.web.static
to create a static resource to servefortune.rpy
- create a resource that returns the output of a process run on the serverreport.rpy
- display various properties of a resource, including path, host, and portusers.rpy
- usetwisted.web.distrib
to publish user directories as for a “community web site”simple.rtl
- example use oftwisted.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