I understand how to write a python cgi script, but I don't understand how to execute it from the web page, which should be simple, right?
Right now my HTML is:
- Code: Select all
<html>
<head>
<title>Spinning Cow with Randomly Generated Colors and Flashes</title>
</head>
<body>
<form action = "CGIRand.cgi">
</form>
</body>
</html>
(And in case you're curious, here's the Python .cgi code:
- Code: Select all
#!"E:\computer stuff\python\python.exe"
from imgShimmerGenerate import *
import cgi
import cgitb
cgitb.enable()
def transformToPrint(str):
return "print(\"" + str + "\")\n"
originalTextFile = open("SpinningCowFramework.html", "r")
cgiText = ""
f = originalTextFile.readlines()
for x in f:
cgiText += transformToPrint(x.rstrip().replace("\"", "\\\""))
ranArray = generateRandomIMGShimmer(200, 7).split('\n')
for line in ranArray:
#print(line)
cgiText += transformToPrint(line)
cgiText += transformToPrint("}")
firstColorString = "RGB(" + str(random.randint(0,255)) + ", " + str(random.randint(0,255)) + ", " + str(random.randint(0,255)) + ")"
secondColorString = "RGB(" + str(random.randint(0,255)) + ", " + str(random.randint(0,255)) + ", " + str(random.randint(0,255)) + ")"
cgiText += transformToPrint("@keyframes backgroundColorChange{0%{background-color: " + firstColorString + "}") + transformToPrint("50%{background-color: " + secondColorString + "}") + transformToPrint("100%{backgroundcolor: " + firstColorString + "}") + transformToPrint("}")
cgiText += transformToPrint("</style></head><body><a href=\\\"http://www.starrandco.zenfolio.com\\\"><img src=\\\"hiCows.jpg\\\"></a></body></html>")
#################
print("Content-type: text/html\r\n\r")
print(cgiText)
#################
#print(cgiText.split("<!--")[0])
#print(cgiText.split("<!--")[1])
#print(cgiText.split("<!--")[2])
#cgiArray = cgiText.split("<!--sub-->")
# @keyframes backgroundColorChange{
# 0%{background-color: #D5D2FD;}
# 50%{background-color: #FAFDD2;}
# 100%{background-color: #D5D2FD;}
# }
And the reference file (HTML/CSS):
- Code: Select all
<!DOCTYPE html>
<html>
<head>
<title>The Spinning Cow</title>
<style>
body{
animation: backgroundColorChange 5s infinite;
}
img{
display: block;
width: 40%;
margin: auto;
position: relative;
top: 120px;
transition: border-radius 1s;
}img:hover{
border-radius:50%;
animation: rotateIMG 6s 1s infinite, imgRadiate3 3s infinite;
}img:not(:hover){
animation: rotateIMG 6s 1s infinite paused, imgRadiate3 3s infinite paused;
}
@keyframes rotateIMG{
0%{transform: rotate(0deg);}
100%{transform: rotate(360deg);}
}
@keyframes imgRadiate3{
)
Thanks in advance. You guys rock!