New UI, Directories at bottom

This commit is contained in:
Violet 2024-02-02 20:08:21 +00:00 committed by GitHub
parent e8744777fa
commit 6ad22ecf55
2 changed files with 22 additions and 1 deletions

View file

@ -29,6 +29,8 @@ app.get("/*", (req, res) => {
res.setHeader('Content-Type', 'text/html') res.setHeader('Content-Type', 'text/html')
res.setHeader("X-Accel-Buffering", "no")
try { try {
var dirContents = fs.readdirSync(absPath) var dirContents = fs.readdirSync(absPath)
} catch (error) { } catch (error) {
@ -42,11 +44,27 @@ app.get("/*", (req, res) => {
res.write('<a href="../">Parent Directory</a><br>') res.write('<a href="../">Parent Directory</a><br>')
} }
var dirs = []
for (let index = 0; index < dirContents.length; index++) { for (let index = 0; index < dirContents.length; index++) {
const file = dirContents[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.write(baseEnd)
res.end() res.end()

View file

@ -4,6 +4,9 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://violets-purgatory.dev/style.css">
<title>{TITLE}</title> <title>{TITLE}</title>
</head> </head>
<body> <body>