1 <?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html lang="en" xmlns="http://www.w3.org/1999/xhtml">
3 <title>Twisted Documentation: Twisted Web code examples</title>
4 <link href="../howto/stylesheet.css" rel="stylesheet" type="text/css"/>
8 <h1 class="title">Twisted Web code examples</h1>
9 <div class="toc"><ol><li><a href="#auto0">twisted.web.client</a></li><li><a href="#auto1">XML-RPC</a></li><li><a href="#auto2">Virtual hosts and proxies</a></li><li><a href="#auto3">.rpys and ResourceTemplate</a></li><li><a href="#auto4">Miscellaneous</a></li></ol></div>
13 <h2>twisted.web.client<a name="auto0"/></h2>
15 <li><a href="getpage.py" shape="rect">getpage.py</a> - use
16 <code>twisted.web.client.getPage</code> to download a web
18 <li><a href="dlpage.py" shape="rect">dlpage.py</a> - add callbacks to
19 <code>twisted.web.client.downloadPage</code> to display errors
20 that occur when downloading a web page</li>
23 <h2>XML-RPC<a name="auto1"/></h2>
25 <li><a href="xmlrpc.py" shape="rect">xmlrpc.py</a> XML-RPC server with
26 several methods, including echoing, faulting, returning
27 deferreds and failed deferreds</li>
28 <li><a href="xmlrpcclient.py" shape="rect">xmlrpcclient.py</a> - use
29 <code>twisted.web.xmlrpc.Proxy</code> to call remote XML-RPC
31 <li><a href="advogato.py" shape="rect">advogato.py</a> - use
32 <code>twisted.web.xmlrpc</code> to post a diary entry to
33 advogato.org; requires an advogato account</li>
36 <h2>Virtual hosts and proxies<a name="auto2"/></h2>
38 <li><a href="proxy.py" shape="rect">proxy.py</a> -
39 use <code>twisted.web.proxy.Proxy</code> to make the simplest
41 <li><a href="logging-proxy.py" shape="rect">logging-proxy.py</a> - example of
42 subclassing the core classes of <code>twisted.web.proxy</code>
43 to log requests through a proxy</li>
44 <li><a href="reverse-proxy.py" shape="rect">reverse-proxy.py</a> - use
45 <code>twisted.web.proxy.ReverseProxyResource</code> to make
46 any HTTP request to the proxy port get applied to a specified
48 <li><a href="rootscript.py" shape="rect">rootscript.py</a> - example use of
49 <code>twisted.web.vhost.NameVirtualHost</code></li>
50 <li><a href="web.py" shape="rect">web.py</a> - an example of both using the
51 <code>processors</code> attribute to set how certain file types
53 <code>twisted.web.vhost.VHostMonsterResource</code> to reverse
57 <h2>.rpys and ResourceTemplate<a name="auto3"/></h2>
59 <li><a href="hello.rpy.py" shape="rect">hello.rpy.py</a> - use
60 <code>twisted.web.static</code> to create a static resource to
62 <li><a href="fortune.rpy.py" shape="rect">fortune.rpy.py</a> - create a
63 resource that returns the output of a process run on the
65 <li><a href="lj.rpy.py" shape="rect">lj.rpy.py</a> - use
66 <code>twisted.web.microdom</code>,
67 <code>twisted.web.domhelpers</code>, and chained callbacks to
68 extract and display parts of a livejournal user's rss page</li>
69 <li><a href="report.rpy.py" shape="rect">report.rpy.py</a> - display
70 various properties of a resource, including path, host, and
72 <li><a href="users.rpy.py" shape="rect">users.rpy.py</a> - use
73 <code>twisted.web.distrib</code> to publish user directories
74 as for a "community web site"</li>
75 <li><a href="simple.rtl" shape="rect">simple.rtl</a> - example use of
76 <code>twisted.web.resource.ResourceTemplate</code></li>
79 <h2>Miscellaneous<a name="auto4"/></h2>
81 <li><a href="webguard.py" shape="rect">webguard.py</a> - pairing
82 <code>twisted.web</code> with <code>twisted.cred</code> to
83 guard resources against unauthenticated users</li>
84 <li><a href="silly-web.py" shape="rect">silly-web.py</a> - bare-bones
85 distributed web setup with a master and slave using
86 <code>twisted.web.distrib</code> and
87 <code>twisted.spread.pb</code></li>
88 <li><a href="google.py" shape="rect">google.py</a> - use
89 <code>twisted.web.google</code> to get the I'm Feeling Lucky
90 page for a search term</li>
91 <li><a href="soap.py" shape="rect">soap.py</a> - use
92 <code>twisted.web.soap</code> to publish SOAP methods</li>
97 <p><a href="../howto/index.html">Index</a></p>
98 <span class="version">Version: 12.1.0</span>