Fix error message, add password variable
This commit is contained in:
parent
637f236c67
commit
e4de5a91ee
1 changed files with 4 additions and 2 deletions
6
index.js
6
index.js
|
@ -7,18 +7,19 @@ var app = express()
|
||||||
var PORT = process.env.PORT || 8080
|
var PORT = process.env.PORT || 8080
|
||||||
|
|
||||||
var directory = process.env.FILES_DIR
|
var directory = process.env.FILES_DIR
|
||||||
|
var passwd = process.env.PASSWORD
|
||||||
|
|
||||||
var baseHTML = fs.readFileSync(path.join(__dirname, 'resources/base.html')).toString()
|
var baseHTML = fs.readFileSync(path.join(__dirname, 'resources/base.html')).toString()
|
||||||
var baseStart = baseHTML.substring(0, baseHTML.indexOf('{CONTENT}'))
|
var baseStart = baseHTML.substring(0, baseHTML.indexOf('{CONTENT}'))
|
||||||
var baseEnd = baseHTML.substring(baseHTML.indexOf('{CONTENT}') + 9, baseHTML.length)
|
var baseEnd = baseHTML.substring(baseHTML.indexOf('{CONTENT}') + 9, baseHTML.length)
|
||||||
|
|
||||||
app.use(express.static(directory))
|
|
||||||
|
|
||||||
if (!directory) {
|
if (!directory) {
|
||||||
console.error("No directory specified! Please specify one using the environment variable FILES_DIR.")
|
console.error("No directory specified! Please specify one using the environment variable FILES_DIR.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.use(express.static(directory))
|
||||||
|
|
||||||
app.listen(PORT, () => {
|
app.listen(PORT, () => {
|
||||||
console.log("Now listening on PORT: " + PORT)
|
console.log("Now listening on PORT: " + PORT)
|
||||||
})
|
})
|
||||||
|
@ -30,6 +31,7 @@ app.get("/*", (req, res) => {
|
||||||
var dirContents = fs.readdirSync(absPath)
|
var dirContents = fs.readdirSync(absPath)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.send("<p>404: not found!</p>")
|
res.send("<p>404: not found!</p>")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
res.write(baseStart)
|
res.write(baseStart)
|
||||||
|
|
Loading…
Reference in a new issue