mkdirindex 1.0.1 Create index.html on directory
This commit is contained in:
parent
a19389ed1d
commit
03a4107ee1
1 changed files with 8 additions and 7 deletions
|
@ -3,9 +3,9 @@
|
||||||
import sys, re, os, glob
|
import sys, re, os, glob
|
||||||
|
|
||||||
filedir = "/home/wn/www/i21k.de/files/"
|
filedir = "/home/wn/www/i21k.de/files/"
|
||||||
indexname = "index.html"
|
indexfilename = "index.html"
|
||||||
indexmd = "index.md"
|
|
||||||
headline = "Files"
|
headline = "Files"
|
||||||
|
dirindexfile = open(filedir + indexfilename, "w")
|
||||||
|
|
||||||
|
|
||||||
head1 = (
|
head1 = (
|
||||||
|
@ -21,13 +21,13 @@ head2 = "</head><body>"
|
||||||
body1 = '<a class="Statement" href="../">Back</a><br/><br/><hr>'
|
body1 = '<a class="Statement" href="../">Back</a><br/><br/><hr>'
|
||||||
body1 += '<div class="Statement"> Some files. Maybe useful or not.</div> '
|
body1 += '<div class="Statement"> Some files. Maybe useful or not.</div> '
|
||||||
body1 += '<table border="0" class="Neutral">'
|
body1 += '<table border="0" class="Neutral">'
|
||||||
foot = '</table><br/><strong>You can\'t avoid chaos.</strong><br/><hr></body> </html>\n'
|
foot = "</table><br/><strong>You can't avoid chaos.</strong><br/><hr></body> </html>\n"
|
||||||
|
|
||||||
|
|
||||||
print(head1 + style_fn + head2 + body1)
|
dirindexfile.write(head1 + style_fn + head2 + body1)
|
||||||
|
|
||||||
for file in os.listdir(filedir):
|
for file in os.listdir(filedir):
|
||||||
if not re.match("^\.", file) and not file == indexname:
|
if not re.match("^\.", file) and not file == indexfilename:
|
||||||
size = os.lstat(filedir + file).st_size
|
size = os.lstat(filedir + file).st_size
|
||||||
if size > 100000000000:
|
if size > 100000000000:
|
||||||
sizestr = str(int(size / 1073741824)) + " GiB"
|
sizestr = str(int(size / 1073741824)) + " GiB"
|
||||||
|
@ -38,6 +38,7 @@ for file in os.listdir(filedir):
|
||||||
else:
|
else:
|
||||||
sizestr = str(size) + " B"
|
sizestr = str(size) + " B"
|
||||||
|
|
||||||
print("<tr><td><a href=\""+file+"\">"+file+"</a></td><td> ", sizestr, "</td></tr>")
|
line = str('<tr><td><a href="' + str(file) + '">' + str(file) + "</a></td><td> "+sizestr+ "</td></tr>")
|
||||||
|
dirindexfile.write(line)
|
||||||
|
|
||||||
print(foot)
|
dirindexfile.write(foot)
|
||||||
|
|
Loading…
Reference in a new issue