<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div style="font-family:arial, helvetica, sans-serif;font-size:10pt"><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight: bold;">From:</span></b> Michael bridges <micha_el2003@yahoo.com><br><b><span style="font-weight: bold;">To:</span></b> ALAN GAULD <alan.gauld@btinternet.com><br><b><span style="font-weight: bold;">Sent:</span></b> Thursday, 16 June, 2011 1:07:14<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [Tutor] using python to write web page<br></font><br><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font:inherit;" valign="top">> your python code includes html.<div><br>OK, Now I understand.<br><br>> i write the python only code --> web page
<br>> [ do not care if it is html, xhtml, java, javascript, or whatever]<br><br>But a "web page" is by definition html.<br>Thats what makes it a web page.<br><br>Most browsers can display plain text too but they will usually <br>mess up the formatting so that it is hard to read. If you want <br>to do that then just create a normal text file.<br><br>But if you want the browser4 to display it with any kind of <br>formatting you must use html, thats all the browser understands.<br><br></div><div>> if i wanted to write html in the python i would just write the html</div><div>> not sure how else the restate, rewrite<br><br>The reasons for writing the html from Python are that you <br>can insert dynamic content into the html, such as names <br>or values from a database, or from another file:<br><br>#####################<br>contentStart = """"<br><html><body><br><p>Here are the current members of my
club:</p><br>"""<br>contentEnd = """<br></body.</html>"""<br><br>data = ["Eric Idle", "Michael Palin", "Graham Chapman"]<br><br>with open("mywebpage.htm","w") as webpage:<br> webpage.write(contentStart)<br> webpage.write("<ul>\n")<br> for name in data:<br> webpage.write("<li>%s</li>" % name)<br> webpage.write("</ul>\n")<br> webpage.write(contentEnd)<br>#######################<br><br>Now you can regenerate the web file by just adding names to data.<br>(and you could populate data from a text file or database etc)<br> <br>But if you want that to display sensibly in a web browser you <br>need to use html.<br><br>HTH,<br><br>Alan G.<br><br><br>--- On <b>Wed, 6/15/11, ALAN
GAULD <i><alan.gauld@btinternet.com></i></b> wrote:<br><blockquote style="border-left:2px solid rgb(16, 16, 255);margin-left:5px;padding-left:5px;"><br>From: ALAN GAULD <alan.gauld@btinternet.com><br>Subject: Re: [Tutor] using python to write web page<br>To: "Michael bridges" <micha_el2003@yahoo.com><br>Cc: "tutor@python.org"
<tutor@python.org><br>Date: Wednesday, June 15, 2011, 4:54 PM<br><br><div id="yiv162580101"><style type="text/css"><!--#yiv162580101 DIV {margin:0px;}--></style><div style="font-family:arial, helvetica, sans-serif;font-size:10pt;"><br><div style="font-family:arial, helvetica, sans-serif;font-size:10pt;"><b><span style="font-weight:bold;">From:</span></b> Michael bridges <micha_el2003@yahoo.com><br><div style="font-family:arial, helvetica, sans-serif;font-size:10pt;"><font size="2" face="Tahoma"><b><span style="font-weight:bold;">To:</span></b> Alan Gauld <alan.gauld@btinternet.com><br><b><span style="font-weight:bold;">Sent:</span></b> Thursday, 16 June, 2011 0:43:35<br><b><span style="font-weight:bold;">Subject:</span></b> Re: [Tutor] using python to write web page<br></font><br>> i do not want to write html, not in whole or in part, nor in reference.<br>> just 100% python. not from a server.<br><br>The code I showed was 100%
Python that created an html file <br>that could be opened in a browser without a
server.<br><br>> i want to write the python only code and have python <br>> only code make the web page that can be read on <br>> any computer with a web browser.<br><br>Thats exactly what my code does.<br><br>> no server use, no server down load, no server at all.<br><br>Thats exactly what my code does.<br><br>> no python interrupter.<br><br>No idea what you mean here?<br>If you mean no Python interpreter how do you expect to <br>execute the python code?<br>If you mean you want to read the resultant file without <br>using Python then.... thats exactly what my code does.<br><br>So does my sample code meet your needs, or is there <br>some other requirement that you haven't explained yet?<br><br><br>--- On Wed, 6/15/11, Alan Gauld <<a rel="nofollow">alan.gauld@btinternet.com</a>> wrote:<br><br>> Python can create html
files so if you only want to
create<br>> an html file just do it:<br>> <br>> content = """<br>> <html><body><br>> <P>Hello world</p><br>> </body></html>"""<br>> <br>> open("myfile.htm","w").write(contents)<br>> <br><br>Alan G<br></div></div>
</div></div></blockquote></div></td></tr></tbody></table></div></div>
</div></body></html>