<?xml version="1.0" encoding="utf-8"?>
<chapter xmlns:db="http://docbook.org/docbook-ng"
         xmlns:xi="http://www.w3.org/2001/XInclude"
         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
         xml:id="byexample">
  <title>CherryPy By Example</title>
  <para>
    The best way to learn CherryPy is to look at example programs.
  </para>
  <section>
    <title>Hello World</title>
    <para>Save the code under a file named helloworld.py.
    Then to start up the application, type the following command:</para>
    <cmdsynopsis>
      <command>python</command>
      <arg choice="req">helloworld.py</arg>
    </cmdsynopsis>
    <para>You will see some information on your terminal window which
    are the log of the web server.</para>
    <para>Then simply point your browser to http://localhost:8080 and 
    say Bravo!</para>
    <example>
      <title>Hello World</title>
      <programlisting>
        <code language="python">
          <xi:include parse="text" href="../../../cherrypy/tutorial/tut01_helloworld.py" />
        </code>
      </programlisting>
    </example>
  </section>

  <section>
    <title>Exposed Methods</title>
    <para>
    For security reasons, CherryPy requires developers to explicitly specify which methods may
    be accessed via the web. The method's 'exposed' attribute, when True, indicates that a given
    method is published to the web.
    </para>
    <example>
      <title>Exposed Methods</title>
      <programlisting>
        <code language="python">
          <xi:include parse="text" href="../../../cherrypy/tutorial/tut02_expose_methods.py" />
        </code>
      </programlisting>
    </example>
  </section>

  <!-- lets save this for later 
  
  <section>
    <title>Get and Post</title>
    <para>
    The majority of web applications need to deal with HTML forms and consequently HTTP GET and POST.
    GET and POST variables are automatically decoded and passed to exposed methods as named arguments.
    </para>
    <example>
      <title>Get and Post</title>
      <programlisting>
        <code language="python">
          <xi:include parse="text" href="../../../cherrypy/tutorial/tut03_get_and_post.py" />
        </code>
      </programlisting>
    </example>
  </section>

  <section>
    <title>Complex Site</title>
    <example>
      <title>Complex Site</title>
      <programlisting>
        <code language="python">
          <xi:include parse="text" href="../../../cherrypy/tutorial/tut04_complex_site.py" />
        </code>
      </programlisting>
    </example>
  </section>

  <section>
    <title>Derived Objects</title>
    <example>
      <title>Derived Objects</title>
      <programlisting>
        <code language="python">
          <xi:include parse="text" href="../../../cherrypy/tutorial/tut05_derived_objects.py" />
        </code>
      </programlisting>
    </example>
  </section>

  <section>
    <title>Default Method</title>
    <example>
      <title>Default Method</title>
      <programlisting>
        <code language="python">
          <xi:include parse="text" href="../../../cherrypy/tutorial/tut06_default_method.py" />
        </code>
      </programlisting>
    </example>
  </section>

  <section>
    <title>Sessions</title>
    <example>
      <title>Sessions</title>
      <programlisting>
        <code language="python">
          <xi:include parse="text" href="../../../cherrypy/tutorial/tut07_sessions.py" />
        </code>
      </programlisting>
    </example>
  </section>

  <section>
    <title>Generator</title>
    <example>
      <title>Generator</title>
      <programlisting>
        <code language="python">
          <xi:include parse="text" href="../../../cherrypy/tutorial/tut08_generators_and_yield.py" />
        </code>
      </programlisting>
    </example>
  </section>

  <section>
    <title>Session Filter</title>
    <example>
      <title>Session Filter</title>
      <programlisting>
        <code language="python">
          <xi:include parse="text" href="../../../cherrypy/tutorial/tut09_sessionfilter.py" />
        </code>
      </programlisting>
    </example>
  </section>

  <section>
    <title>File Upload</title>
    <example>
      <title>File Upload</title>
      <programlisting>
        <code language="python">
          <xi:include parse="text" href="../../../cherrypy/tutorial/tut10_file_upload.py" />
        </code>
      </programlisting>
    </example>
  </section>

  -->
  <xi:include href="buildingblog.xml" />
</chapter>
