1.1 --- a/docs/resources.html Sat Jan 20 23:15:29 2007 +0000
1.2 +++ b/docs/resources.html Sat Jan 20 23:16:22 2007 +0000
1.3 @@ -4,7 +4,6 @@
1.4
1.5 <title>Applications and Resources</title><meta name="generator" content="amaya 8.1a, see http://www.w3.org/Amaya/" />
1.6 <link href="styles.css" rel="stylesheet" type="text/css" /></head>
1.7 -
1.8 <body>
1.9 <h1>Applications and Resources</h1>
1.10 At its simplest a WebStack application is just a single Python
1.11 @@ -50,17 +49,16 @@
1.12 <h2>Testing the Resource</h2>
1.13 <p>To test this resource we need to deploy it, and to do that we need
1.14 an
1.15 -adapter. Here is a quick way of writing an adapter and testing this
1.16 +adapter to connect it to the outside world. Here is a quick way of writing an adapter and testing this
1.17 code:</p>
1.18 <ol>
1.19 <li> Create a file called <code>MyAdapter.py</code> - you
1.20 can choose another name if you want - this will be where the adapter
1.21 code lives.</li>
1.22 - <li>Copy the example adapter in <a href="deploying.html">"Deploying
1.23 -a WebStack Application"</a> and write it into <code>MyAdapter.py</code>.</li>
1.24 - <li>Now, with two files in your directory, <code>MyApplication.py</code>
1.25 + <li>Write into it the following code:</li></ol><pre>from WebStack.Adapters.BaseHTTPRequestHandler import deploy # import the support for the server environment<br />from MyApplication import MyResource # import the main resource class<br />print "Serving..." # just for testing - we might want to remove this later<br />deploy(MyResource()) # connect a resource object to the server environment</pre><p>Now, with two files in your directory, <code>MyApplication.py</code>
1.26 and <code>MyAdapter.py</code>, you may run <code>MyAdapter.py</code>
1.27 -as follows:</li>
1.28 +as follows:</p><ol>
1.29 +
1.30 </ol>
1.31 <pre>python MyAdapter.py</pre>
1.32 <p>This should start the adapter program and print the following
1.33 @@ -68,5 +66,4 @@
1.34 <pre>Serving...</pre>
1.35 <p>You should now be able to visit <code>http://localhost:8080</code>
1.36 in your
1.37 -browser and see the message printed by your application:</p>
1.38 -<pre>Hello world.</pre></body></html>
1.39 \ No newline at end of file
1.40 +browser and see the message printed by your application:</p><pre>Hello world.</pre><h2>Related Examples</h2><p>The code presented in this document is very similar to that found in the following files:</p><ul><li><code>examples/Common/VerySimple/__init__.py</code> (where a package, <code>VerySimple</code>, is used to hold a <code>VerySimpleResource</code> class)</li><li><code>examples/BaseHTTPRequestHandler/VerySimpleApp.py</code> (where the resource is deployed)</li></ul><p>Note that a number of different adapters are provided in the <code>examples</code> directory hierarchy; for example:</p><ul><li><code>examples/CGI/VerySimpleHandler.py</code> (deploys the example as a CGI script)</li><li><code>examples/Twisted/VerySimpleApp.py</code> (deploys the example as a Twisted application)</li></ul><p>See <a href="deploying.html">"Deploying a WebStack Application"</a> for more information about adapters.</p></body></html>
1.41 \ No newline at end of file