| 1 |
|
| 2 |
:LastChangedDate: $LastChangedDate$ |
| 3 |
:LastChangedRevision: $LastChangedRevision$ |
| 4 |
:LastChangedBy: $LastChangedBy$ |
| 5 |
|
| 6 |
Examples |
| 7 |
======== |
| 8 |
|
| 9 |
twisted.web.client |
| 10 |
------------------ |
| 11 |
|
| 12 |
- :download:`httpclient.py` - use ``twisted.web.client.Agent`` to download a web page. |
| 13 |
- (deprecated) :download:`getpage.py` - use ``twisted.web.client.getPage`` to download a web page. |
| 14 |
- (deprecated) :download:`dlpage.py` - add callbacks to ``twisted.web.client.downloadPage`` to display errors that occur when downloading a web page |
| 15 |
|
| 16 |
|
| 17 |
XML-RPC |
| 18 |
------- |
| 19 |
|
| 20 |
- :download:`xmlrpcserver.py` XML-RPC server with several methods, including echoing, faulting, returning deferreds and failed deferreds |
| 21 |
- :download:`xmlrpcclient.py` - use ``twisted.web.xmlrpc.Proxy`` to call remote XML-RPC methods |
| 22 |
- :download:`xmlrpc-debug.py` - use ``xmlrpc.Proxy``'s ``queryFactory`` to debug raw XML-RPC traffic |
| 23 |
- :download:`advogato.py` - use ``twisted.web.xmlrpc`` to post a diary entry to advogato.org; requires an advogato account |
| 24 |
|
| 25 |
|
| 26 |
Virtual hosts and proxies |
| 27 |
------------------------- |
| 28 |
|
| 29 |
- :download:`proxy.py` - use ``twisted.web.proxy.Proxy`` to make the simplest proxy |
| 30 |
- :download:`logging-proxy.py` - example of subclassing the core classes of ``twisted.web.proxy`` to log requests through a proxy |
| 31 |
- :download:`reverse-proxy.py` - use ``twisted.web.proxy.ReverseProxyResource`` to make any HTTP request to the proxy port get applied to a specified website |
| 32 |
- :download:`rootscript.py` - example use of ``twisted.web.vhost.NameVirtualHost`` |
| 33 |
- :download:`web.py` - an example of both using the ``processors`` attribute to set how certain file types are treated and using ``twisted.web.vhost.VHostMonsterResource`` to reverse proxy |
| 34 |
|
| 35 |
|
| 36 |
.rpys and ResourceTemplate |
| 37 |
-------------------------- |
| 38 |
|
| 39 |
- :download:`hello.rpy` - use ``twisted.web.static`` to create a static resource to serve |
| 40 |
- :download:`fortune.rpy` - create a resource that returns the output of a process run on the server |
| 41 |
- :download:`report.rpy` - display various properties of a resource, including path, host, and port |
| 42 |
- :download:`users.rpy` - use ``twisted.web.distrib`` to publish user directories as for a "community web site" |
| 43 |
- :download:`simple.rtl` - example use of ``twisted.web.resource.ResourceTemplate`` |
| 44 |
|
| 45 |
|
| 46 |
Miscellaneous |
| 47 |
------------- |
| 48 |
|
| 49 |
- :download:`webguard.py` - pairing ``twisted.web`` with ``twisted.cred`` to guard resources against unauthenticated users |
| 50 |
- :download:`silly-web.py` - bare-bones distributed web setup with a master and slave using ``twisted.web.distrib`` and ``twisted.spread.pb`` |