Software to install :
1.Apache (https://httpd.apache.org/)
2.cx_Freeze (http://cx-freeze.sourceforge.net/)
After installed these 2 software, visit your httpd.conf of on your apache, such as in this location:
C:\AppServ\Apache2.2\conf\httpd.confUse CTRL +F to look for this line:
Options Indexes FollowSymLinks MultiViews
If you found there is the text ExexCGI at the end of this sentence, you need to amend nothing, otherwise you need to add it:
Options Indexes FollowSymLinks MultiViews ExexCGIAnd then look for another lines by CTRL+F and uncomment that, and then add the text .py
# AddHandler cgi-script .cgi .py
Save this file.
Visit ‘control panel’->’system adminstruct tool’’-> ‘service’, select Apache2.2, right click and restart this apache web service.
Create a file and save in Apache directory such as C:\AppServ\www, named web.py with these content:
First 2 lines and line 4 is necessary, first line is to tell this file to find the directory of pyhton compiler. Line 4 means the end of header, if without this line would cause 500 Internal Server Error.
#!C:/Pyhton/python
#coding:utf-8
print(“Content-Type:text/html;charset=utf-8”)
print(“”)
print(“<html>”)
print(“<body>”)
print(“<head>”)
print(“<title>I am a webpage</title>”)
print(“<h1>This is h1 title </h1>”)
print(“<p>I am using python.</p>”)
print(“</head>”)
print(“</body>”)
print(“</html>”)
Visit this url:
http://localhost/web.py
No comments :
Post a Comment