<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="Description" content="An event-driven networking engine written in Python and MIT licensed." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Examples — Twisted 16.0.0 documentation</title>
<link rel="stylesheet" href="../../_static/twistedtrac.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../../',
VERSION: '16.0.0',
COLLAPSE_MODINDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../../_static/jquery.js"></script>
<script type="text/javascript" src="../../_static/underscore.js"></script>
<script type="text/javascript" src="../../_static/doctools.js"></script>
<link rel="top" title="Twisted 16.0.0 documentation" href="../../index.html" />
<link rel="up" title="Twisted Web" href="../index.html" />
<link rel="next" title="Twisted Words" href="../../words/index.html" />
<link rel="prev" title="Glossary" href="../howto/glossary.html" />
<!-- Can stuff between these comments go? -->
<link rel="search" href="/trac/search" />
<link rel="help" href="/trac/wiki/TracGuide" />
<link rel="alternate" href="/trac/wiki/Documentation?format=txt" type="text/x-trac-wiki" title="Plain Text" />
<link rel="start" href="/trac/wiki" />
<script type="text/javascript" src="/trac/chrome/common/js/jquery.js"></script><script type="text/javascript" src="/trac/chrome/common/js/trac.js"></script><script type="text/javascript" src="/trac/chrome/common/js/search.js"></script>
<!-- the following script tag is a holdover frome Trac, which shouldn't be needed in Sphinx
<script type="text/javascript">
$(document).ready(function() {
$("#content").find("h1,h2,h3,h4,h5,h6").addAnchor("Link to this section");
});
</script>
-->
<!-- Can stuff between these comments go? -->
</head>
<body>
<div id="banner">
<div id="top_grad">
</div>
<div id="tab">
<a href="http://twistedmatrix.com/trac/wiki">HOME</a>
<a href="http://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions">FAQ</a>
<a href="/">DOCS</a>
<a href="http://twistedmatrix.com/trac/wiki/Downloads">DOWNLOAD</a>
</div>
<div id="header">
<a id="logo" href="http://twistedmatrix.com/trac/"><img src="../../_static/trac_banner.png" alt="Twisted" /></a>
</div>
<!-- taking this out for now, but might use
the space for something else later
-->
<!--
<form id="topsearch" action="/trac/search" method="get"><div>
<label for="proj-search">Search:</label>
<input type="text" id="proj-search" name="q" size="10" value="" />
<input type="submit" value="Search" />
<input type="hidden" name="wiki" value="on" />
<input type="hidden" name="changeset" value="on" />
<input type="hidden" name="ticket" value="on" />
</div></form>
-->
<div id="metanav" class="nav">
<ul>
<li> </li>
<!-- taking this out for now, but might use
the space for something else later
-->
<!--
<li class="first">logged in as khorn</li><li class=""><a href="/trac/logout">Logout</a></li><li class=""><a href="/trac/wiki/TracGuide">Help/Guide</a></li><li class=""><a href="/trac/about">About Trac</a></li><li class="last"><a href="/trac/account">My Account</a></li>
-->
</ul>
</div>
</div>
<!-- mainnav -->
<div id="mainnav" class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../../words/index.html" title="Twisted Words"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="../howto/glossary.html" title="Glossary"
accesskey="P">previous</a> |</li>
<li><a href="../../index.html">Twisted 16.0.0 documentation</a> »</li>
<li><a href="../index.html" accesskey="U">Twisted Web</a> »</li>
</ul>
</div>
<div id="main">
<div id="ctxtnav" class="nav">
<h2>Wiki Navigation</h2>
<ul>
<li>
</li>
<!-- taking this out for now, but might use
the space for something else later
-->
<!--
<li><a href="/trac/wiki/WikiStart">Start Page</a></li>
<li><a href="/trac/wiki/TitleIndex">Index by Title</a></li>
<li><a href="/trac/wiki/RecentChanges">Index by Date</a></li>
<li class="last">
<a href="/trac/wiki/Documentation?action=diff&version=15">Last Change</a>
</li>
-->
</ul>
<hr />
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div id="current-docs-container" style="display: none">
<em>
<a id="current-docs-link">
Go to the latest version of this document.
</a>
</em>
</div>
<div class="body">
<div class="section" id="examples">
<h1>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h1>
<div class="section" id="twisted-web-client">
<h2>twisted.web.client<a class="headerlink" href="#twisted-web-client" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li><a class="reference download internal" href="../../_downloads/getpage.py"><code class="xref download docutils literal"><span class="pre">getpage.py</span></code></a> - use <code class="docutils literal"><span class="pre">twisted.web.client.getPage</span></code> to download a web page.</li>
<li><a class="reference download internal" href="../../_downloads/dlpage.py"><code class="xref download docutils literal"><span class="pre">dlpage.py</span></code></a> - add callbacks to <code class="docutils literal"><span class="pre">twisted.web.client.downloadPage</span></code> to display errors that occur when downloading a web page</li>
</ul>
</div>
<div class="section" id="xml-rpc">
<h2>XML-RPC<a class="headerlink" href="#xml-rpc" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li><a class="reference download internal" href="../../_downloads/xmlrpc.py"><code class="xref download docutils literal"><span class="pre">xmlrpc.py</span></code></a> XML-RPC server with several methods, including echoing, faulting, returning deferreds and failed deferreds</li>
<li><a class="reference download internal" href="../../_downloads/xmlrpcclient.py"><code class="xref download docutils literal"><span class="pre">xmlrpcclient.py</span></code></a> - use <code class="docutils literal"><span class="pre">twisted.web.xmlrpc.Proxy</span></code> to call remote XML-RPC methods</li>
<li><a class="reference download internal" href="../../_downloads/advogato.py"><code class="xref download docutils literal"><span class="pre">advogato.py</span></code></a> - use <code class="docutils literal"><span class="pre">twisted.web.xmlrpc</span></code> to post a diary entry to advogato.org; requires an advogato account</li>
</ul>
</div>
<div class="section" id="virtual-hosts-and-proxies">
<h2>Virtual hosts and proxies<a class="headerlink" href="#virtual-hosts-and-proxies" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li><a class="reference download internal" href="../../_downloads/proxy.py"><code class="xref download docutils literal"><span class="pre">proxy.py</span></code></a> - use <code class="docutils literal"><span class="pre">twisted.web.proxy.Proxy</span></code> to make the simplest proxy</li>
<li><a class="reference download internal" href="../../_downloads/logging-proxy.py"><code class="xref download docutils literal"><span class="pre">logging-proxy.py</span></code></a> - example of subclassing the core classes of <code class="docutils literal"><span class="pre">twisted.web.proxy</span></code> to log requests through a proxy</li>
<li><a class="reference download internal" href="../../_downloads/reverse-proxy.py"><code class="xref download docutils literal"><span class="pre">reverse-proxy.py</span></code></a> - use <code class="docutils literal"><span class="pre">twisted.web.proxy.ReverseProxyResource</span></code> to make any HTTP request to the proxy port get applied to a specified website</li>
<li><a class="reference download internal" href="../../_downloads/rootscript.py"><code class="xref download docutils literal"><span class="pre">rootscript.py</span></code></a> - example use of <code class="docutils literal"><span class="pre">twisted.web.vhost.NameVirtualHost</span></code></li>
<li><a class="reference download internal" href="../../_downloads/web.py"><code class="xref download docutils literal"><span class="pre">web.py</span></code></a> - an example of both using the <code class="docutils literal"><span class="pre">processors</span></code> attribute to set how certain file types are treated and using <code class="docutils literal"><span class="pre">twisted.web.vhost.VHostMonsterResource</span></code> to reverse proxy</li>
</ul>
</div>
<div class="section" id="rpys-and-resourcetemplate">
<h2>.rpys and ResourceTemplate<a class="headerlink" href="#rpys-and-resourcetemplate" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li><a class="reference download internal" href="../../_downloads/hello.rpy.py"><code class="xref download docutils literal"><span class="pre">hello.rpy.py</span></code></a> - use <code class="docutils literal"><span class="pre">twisted.web.static</span></code> to create a static resource to serve</li>
<li><a class="reference download internal" href="../../_downloads/fortune.rpy.py"><code class="xref download docutils literal"><span class="pre">fortune.rpy.py</span></code></a> - create a resource that returns the output of a process run on the server</li>
<li><a class="reference download internal" href="../../_downloads/report.rpy.py"><code class="xref download docutils literal"><span class="pre">report.rpy.py</span></code></a> - display various properties of a resource, including path, host, and port</li>
<li><a class="reference download internal" href="../../_downloads/users.rpy.py"><code class="xref download docutils literal"><span class="pre">users.rpy.py</span></code></a> - use <code class="docutils literal"><span class="pre">twisted.web.distrib</span></code> to publish user directories as for a “community web site”</li>
<li><a class="reference download internal" href="../../_downloads/simple.rtl"><code class="xref download docutils literal"><span class="pre">simple.rtl</span></code></a> - example use of <code class="docutils literal"><span class="pre">twisted.web.resource.ResourceTemplate</span></code></li>
</ul>
</div>
<div class="section" id="miscellaneous">
<h2>Miscellaneous<a class="headerlink" href="#miscellaneous" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li><a class="reference download internal" href="../../_downloads/webguard.py"><code class="xref download docutils literal"><span class="pre">webguard.py</span></code></a> - pairing <code class="docutils literal"><span class="pre">twisted.web</span></code> with <code class="docutils literal"><span class="pre">twisted.cred</span></code> to guard resources against unauthenticated users</li>
<li><a class="reference download internal" href="../../_downloads/silly-web.py"><code class="xref download docutils literal"><span class="pre">silly-web.py</span></code></a> - bare-bones distributed web setup with a master and slave using <code class="docutils literal"><span class="pre">twisted.web.distrib</span></code> and <code class="docutils literal"><span class="pre">twisted.spread.pb</span></code></li>
<li><a class="reference download internal" href="../../_downloads/soap.py"><code class="xref download docutils literal"><span class="pre">soap.py</span></code></a> - use <code class="docutils literal"><span class="pre">twisted.web.soap</span></code> to publish SOAP methods</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="../../index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Examples</a><ul>
<li><a class="reference internal" href="#twisted-web-client">twisted.web.client</a></li>
<li><a class="reference internal" href="#xml-rpc">XML-RPC</a></li>
<li><a class="reference internal" href="#virtual-hosts-and-proxies">Virtual hosts and proxies</a></li>
<li><a class="reference internal" href="#rpys-and-resourcetemplate">.rpys and ResourceTemplate</a></li>
<li><a class="reference internal" href="#miscellaneous">Miscellaneous</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="../howto/glossary.html"
title="previous chapter">Glossary</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="../../words/index.html"
title="next chapter">Twisted Words</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../../_sources/web/examples/index.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="../../search.html" method="get">
<p>
<input type="text" name="q" size="18" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</p>
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
</div>
<div id="footer"><hr />
<div>
</div>
<p class="left2">
Site design<br />
By <a href="http://huw.ugbox.net/">huw.wilkins.</a>
</p>
<p class="right"></p>
</div>
<script type="text/javascript">
if (window.location.pathname.indexOf('/current/') == -1) {
<!-- Give the user a link to this page, but in the current version of the docs. -->
var link = document.getElementById('current-docs-link');
link.href = window.location.pathname.replace(/\/\d+\.\d+\.\d+/, '/current');
<!-- And make it visible -->
var container = document.getElementById('current-docs-container');
container.style.display = '';
delete link;
delete container;
}
</script>
</body>
</html>
Copyright 2K16 - 2K18 Indonesian Hacker Rulez