37 lines
724 B
JavaScript
37 lines
724 B
JavaScript
const express = require('express')
|
|
const app = express()
|
|
const port = 3000
|
|
|
|
app.use(express.static("public"))
|
|
|
|
const documentRoot = `${__dirname}/httpdocs`
|
|
|
|
|
|
app.get('/', (req, res) => {
|
|
res.sendFile(documentRoot+"/index.html")
|
|
})
|
|
|
|
app.get("/execute", (req, res)=> {
|
|
const raw_command = req.query.command;
|
|
const formatted_command = String(raw_command).trim();
|
|
|
|
console.log(`Executed Command: ${formatted_command}`);
|
|
|
|
if (formatted_command.startsWith("ls")){
|
|
LS(req, res);
|
|
}
|
|
else {
|
|
res.json({"response": "invalid command"})
|
|
}
|
|
})
|
|
|
|
app.listen(port, () => {
|
|
console.log(`Example app listening on port ${port}`)
|
|
})
|
|
|
|
|
|
|
|
function LS (req, res) {
|
|
res.json({"response": "LS IS WEL FICKING EPISCH"});
|
|
|
|
} |