<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Autogeneration of web pages' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Autogeneration of web pages' posted on the 'Python' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Tue, 18 Jun 2013 18:11:09 -0700</pubDate>
    <lastBuildDate>Tue, 18 Jun 2013 18:11:09 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Autogeneration of web pages</title>
      <link>http://www.programmersheaven.com/mb/python/180355/180355/autogeneration-of-web-pages/</link>
      <description>Hello python fans,&lt;br /&gt;
&lt;br /&gt;
I am a bit new to python and already liking this great language. I was trying to autogenerate html pages from cgi scripts. Basically I need to write a Python program to take a file marked up using the following system: &lt;br /&gt;
&lt;br /&gt;
'* filename title' - creates a file using the given filename (with '.html' appended) and gives it the given title, both at the top of the browser (in the &amp;lt;title&amp;gt; section) and as a top level heading (&amp;lt;h1&amp;gt;) on the page. &lt;br /&gt;
'**' represents a section heading (&amp;lt;h2&amp;gt;) &lt;br /&gt;
'.' represents a paragraph &lt;br /&gt;
'-' represents an element in an unordered list (&amp;lt;li&amp;gt; in a &amp;lt;ul&amp;gt;) &lt;br /&gt;
'--' represents an element in an unordered list which is in another list &lt;br /&gt;
Markups must begin on the first character of a line &lt;br /&gt;
Markups may span multiple lines &lt;br /&gt;
&lt;br /&gt;
and convert it into valid XHTML 1.0. &lt;br /&gt;
&lt;br /&gt;
PLEASE EMAIL ME IF YOU HAVE ANY QUERIES. I ALREADY HAVE SOME FUNCTIONS DEFINED LIKE get_file and put_file which will be needed for this program. &lt;br /&gt;
&lt;br /&gt;
Thanks,&lt;br /&gt;
pinks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/180355/180355/autogeneration-of-web-pages/</guid>
      <pubDate>Tue, 01 Apr 2003 18:55:45 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Re: Autogeneration of web pages</title>
      <link>http://www.programmersheaven.com/mb/python/180355/180470/re-autogeneration-of-web-pages/#180470</link>
      <description>&lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by Moderator at 2003-4-2 7:17:20&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
: Hello python fans,&lt;br /&gt;
: &lt;br /&gt;
: I am a bit new to python and already liking this great language. I was trying to autogenerate html pages from cgi scripts. Basically I need to write a Python program to take a file marked up using the following system: &lt;br /&gt;
: &lt;br /&gt;
: '* filename title' - creates a file using the given filename (with '.html' appended) and gives it the given title, both at the top of the browser (in the &amp;lt;title&amp;gt; section) and as a top level heading (&amp;lt;h1&amp;gt;) on the page. &lt;br /&gt;
: '**' represents a section heading (&amp;lt;h2&amp;gt;) &lt;br /&gt;
: '.' represents a paragraph &lt;br /&gt;
: '-' represents an element in an unordered list (&amp;lt;li&amp;gt; in a &amp;lt;ul&amp;gt;) &lt;br /&gt;
: '--' represents an element in an unordered list which is in another list &lt;br /&gt;
: Markups must begin on the first character of a line &lt;br /&gt;
: Markups may span multiple lines &lt;br /&gt;
: &lt;br /&gt;
: and convert it into valid XHTML 1.0. &lt;br /&gt;
: &lt;br /&gt;
: PLEASE EMAIL ME IF YOU HAVE ANY QUERIES. I ALREADY HAVE SOME FUNCTIONS DEFINED LIKE get_file and put_file which will be needed for this program. &lt;br /&gt;
&lt;br /&gt;
did you have any specific questions?&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;&lt;em&gt;&lt;span style="color: Blue;"&gt;&lt;span style="color: Red;"&gt;i&lt;/span&gt;nfidel&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/180355/180470/re-autogeneration-of-web-pages/#180470</guid>
      <pubDate>Wed, 02 Apr 2003 07:16:59 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Re: Autogeneration of web pages</title>
      <link>http://www.programmersheaven.com/mb/python/180355/180594/re-autogeneration-of-web-pages/#180594</link>
      <description>I wanted to know how i start the python script; what are the variables needed to be defined.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/180355/180594/re-autogeneration-of-web-pages/#180594</guid>
      <pubDate>Wed, 02 Apr 2003 17:35:18 -0700</pubDate>
      <category>Python</category>
    </item>
    <item>
      <title>Re: Autogeneration of web pages</title>
      <link>http://www.programmersheaven.com/mb/python/180355/180686/re-autogeneration-of-web-pages/#180686</link>
      <description>: I wanted to know how i start the python script; what are the variables needed to be defined.&lt;br /&gt;
&lt;br /&gt;
Oh, well the simplest way to write Python cgi scripts is like this:&lt;br /&gt;
&lt;br /&gt;
The first line should be the "shebang":&lt;br /&gt;
&lt;br /&gt;
On a *NIX system:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;#!/usr/bin/python&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
On a Windows system:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;#!C:\Python22\python.exe&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Of course, the path may be different on your web server.&lt;br /&gt;
&lt;br /&gt;
Then you need to print the header that tells your browser to expect html:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;print 'Content-type: text/html\n'&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Make sure you have the newline at the end!&lt;br /&gt;
&lt;br /&gt;
After that, anything you print will be parsed by the browser as html.  For example:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
#!/usr/bin/python
print 'Content-type: text/html\n'
print """
&amp;lt;html&amp;gt;
    &amp;lt;head&amp;gt;
        &amp;lt;title&amp;gt;My first cgi script!&amp;lt;/title&amp;gt;
    &amp;lt;head&amp;gt;
    &amp;lt;body&amp;gt;
        &amp;lt;h1&amp;gt;Hello, world!&amp;lt;/h1&amp;gt;
    &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
"""
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Then you just drop that script in the cgi-bin on your server and call it with a regular URL in a browser.&lt;br /&gt;
&lt;br /&gt;
Debugging cgi is rather frustrating, but there is a way in python to make it much easier to find code errors.  Just after the shebang line (which must be the first line of the file) put this:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;import cgitb; cgitb.enable()&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
This imports the cgi traceback module.  If any exceptions are raised by your script, you will get a pretty html display of the code and a description of the error and the line that caused it rather than the unhelpful "500: Internal Server Error".&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;&lt;em&gt;&lt;span style="color: Blue;"&gt;&lt;span style="color: Red;"&gt;i&lt;/span&gt;nfidel&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/python/180355/180686/re-autogeneration-of-web-pages/#180686</guid>
      <pubDate>Thu, 03 Apr 2003 07:23:01 -0700</pubDate>
      <category>Python</category>
    </item>
  </channel>
</rss>