Python Hello World

7/10/2015·1 min read

So, you want to get start Python..

Also, you prefer windows enviroment, so let's get start a little bit.

Download Python

Go to this link to download Python, https://www.python.org/downloads/release/python-279/, select the target windows installer.

Good Article

Check this article to get start to use it, https://www.toptal.com/django/installing-django-on-iis-a-step-by-step-tutorial.

 

Sample hello word code for Python

'''A simple program to create an html file froma given string,
and call the default web browser to display the file.'''

contents = '''<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="content-type">
  <title>Hello</title>

</head>
<body>
Hello, World!
<div>
    <input type="text"/>

</div>
</body>
</html>
'''

def main():
    browseLocal(contents)

def strToFile(text, filename):
    """Write a file with the given name and the given text."""
    output = open(filename,"w")
    output.write(text)
    output.close()

def browseLocal(webpageText, filename='tempBrowseLocal.html'):
    '''Start your webbrowser on a local file containing the text
    with given filename.'''
    import webbrowser, os.path
    strToFile(webpageText, filename)
    webbrowser.open("file:///" + os.path.abspath(filename)) #elaborated for Mac

main()

Another sample code for Python

import os
print "Content-type: text/html\r\n\r\n";

for param in os.environ.keys():
  print "<b>%20s</b>: %s<\br>" % (param, os.environ[param])

Something want to try, can I call pass Python command from UI to back-end python code and display result to the UI?