New UI, Directories at bottom
This commit is contained in:
parent
e8744777fa
commit
6ad22ecf55
2 changed files with 22 additions and 1 deletions
20
index.js
20
index.js
|
@ -29,6 +29,8 @@ app.get("/*", (req, res) => {
|
|||
|
||||
res.setHeader('Content-Type', 'text/html')
|
||||
|
||||
res.setHeader("X-Accel-Buffering", "no")
|
||||
|
||||
try {
|
||||
var dirContents = fs.readdirSync(absPath)
|
||||
} catch (error) {
|
||||
|
@ -42,11 +44,27 @@ app.get("/*", (req, res) => {
|
|||
res.write('<a href="../">Parent Directory</a><br>')
|
||||
}
|
||||
|
||||
var dirs = []
|
||||
|
||||
for (let index = 0; index < dirContents.length; index++) {
|
||||
const file = dirContents[index];
|
||||
res.write(`<a href="./${file}">${file}</a><br>`)
|
||||
var fileStats = fs.statSync(path.join(absPath, file))
|
||||
// console.log(fileStats.isDirectory)
|
||||
if (!fileStats.isDirectory()) {
|
||||
res.write(`<a href="./${file}">${file}</a><br>`)
|
||||
} else {
|
||||
dirs.push(file)
|
||||
}
|
||||
}
|
||||
|
||||
for (let index = 0; index < dirs.length; index++) {
|
||||
const file = dirs[index];
|
||||
|
||||
res.write(`<a href="./${file}">./${file}/</a><br>`)
|
||||
|
||||
}
|
||||
// res.write(`<a href="./${file}">./${file}/</a><br>`)
|
||||
|
||||
res.write(baseEnd)
|
||||
|
||||
res.end()
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link rel="stylesheet" href="https://violets-purgatory.dev/style.css">
|
||||
|
||||
<title>{TITLE}</title>
|
||||
</head>
|
||||
<body>
|
||||
|
|
Loading…
Reference in a new issue