我已安装 mod_wsgi
并将其配置为运行 Python 文件 (WSGIScriptAlias /wsgi /var/www/html/test.py
)。
test.py
包含以下内容(它显示 HTML 代码 OK,但将 print()
发送到 apache2 错误日志)。
请问,如何在HTML页面上显示时间:
#!/usr/bin/env python
import sys
import time; # This is required to include time module.
localtime = time.asctime( time.localtime(time.time()) )
print ("Local current time :", localtime, " this got from a Python file<BR>")
def application(environ,start_response):
status = '200 OK'
html = '<html>\n' \
'<CENTER>\n' \
'<HEAD>\n' \
'<title>test.py</title>\n' \
'\n' \
'</HEAD>\n' \
'<body bgcolor="#dbd7d2">\n' \
'<font color="red">\n' \
'Note that if only an extract is to be processed, the entire clip will be downloaded and then the extract will be processed<BR>\n' \
'<font color="black">\n' \
'<FORM action="" method="post">\n' \
'<TABLE>\n' \
'\n' \
'<div style= "text-align:center;">\n' \
'<TD> Select mode for down load</TD>\n' \
'<TD><select id="fullVideo" name="fullVideo" size="2" autocomplete="off"/> \n' \
'<option value="FullVideo" selected>Download full YouTube video</option>\n' \
'<option value="Extract" >Download extract from the YouTube video</option\n>' \
'</SELECT>\n' \
'<TD>\n' \
'\n' \
'</TD>\n' \
'\n' \
'<TR><TD> Enter the URL of the Video to be downoaded</TD><TD><h5 style="color:yellow;" ></h5><input type="text" id="url" name="url" autocomplete="off"/>\n' \
'<TR><TD>Enter start that the download is to be downloaded in (hh:mm:ss) format</TD>\n' \
'<TD><input type="text" id="start" name="start" autocomplete="off"/></TD><TR>\n' \
'<TR><TD>Enter end time that the download is to be downloaded to in (hh:mm:ss) format</TD>\n' \
'<TD><input type="text" id="finish" name="finish" autocomplete="off"/></TD><TR>\n' \
' <button id="button1" style="color: blue"; onclick="validate();">Validate Inputs</button>\n' \
' <button style="color:green"; onclick="startDownload();">Start Download</button>\n' \
'<input style= "background-color: pink"; type="text" id="OkToGo1" name="OkToGo1" value="No">\n' \
'<input style= "background-color: red"; type="text" id="OkToGo2" name="OkToGo2" value="No">\n' \
'<input style= "background-color: yellow"; type="text" id="DoTheDownload" name="DoTheDownload" value="No Download">\n' \
' <TD><CENTER><button id="button3" style="color: blue"; onclick="window.location =localhost/YouTubeAudioDownload.php; ">Enter New Params</button></TD>\n' \
'</TABLE>\n' \
'</div>\n' \
'</form>\n' \
'</body>\n' \
'</html>\n'
response_header = [('Content-type','text/html')]
start_response(status,response_header)
return [html]