Show directory with python
Code :
#!/usr/bin/python
print "content-type: text/html\n\n"
import os
print"""
<head>
<title>Lecture</title>
<style type = 'text/css'>
.style{font-size: 50px;
font-weight:bold;
color: #0B610B;
}
body{background-color:#D8F6CE}
</style>
</head>
<body>
<p align =\"center\"><spen class=\"style\">Directory</spen></p></br></br>
"""
direc = "/home/yuyii/cgi-bin" #find file
sum_ = 0
for di in os.walk(direc): #for dirname, dirnames, filenames in os.walk('direc'):
print "<b>"+di[0]+"</b> : <br>"
for f in di[2]:
size = os.path.getsize(di[0]+"/"+f)
print f+" :: "
print size
print " bytes <br>"
sum_ += size #add size file
print "<br><b> Directory total </b>"
print sum_
print " bytes"
print"</body>\n"
"
print""+"
Lecture Date:011215
------------------------

ไม่มีความคิดเห็น:
แสดงความคิดเห็น