i had to stop becuz online lesson
This commit is contained in:
19
server.js
19
server.js
@@ -2,7 +2,9 @@ const express = require('express')
|
||||
const app = express()
|
||||
const port = 3000
|
||||
|
||||
app.use(express.static("public"))
|
||||
const commands = require("./commands/commands")
|
||||
|
||||
app.use(express.static("httpdocs/public"))
|
||||
|
||||
const documentRoot = `${__dirname}/httpdocs`
|
||||
|
||||
@@ -15,10 +17,12 @@ app.get("/execute", (req, res)=> {
|
||||
const raw_command = req.query.command;
|
||||
const formatted_command = String(raw_command).trim();
|
||||
|
||||
const currentDir = req.query.currentDir
|
||||
|
||||
console.log(`Executed Command: ${formatted_command}`);
|
||||
|
||||
if (formatted_command.startsWith("ls")){
|
||||
LS(req, res);
|
||||
if (formatted_command.startsWith("cd")){
|
||||
commands.cd(req, res);
|
||||
}
|
||||
else {
|
||||
res.json({"response": "invalid command"})
|
||||
@@ -27,11 +31,4 @@ app.get("/execute", (req, res)=> {
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Example app listening on port ${port}`)
|
||||
})
|
||||
|
||||
|
||||
|
||||
function LS (req, res) {
|
||||
res.json({"response": "LS IS WEL FICKING EPISCH"});
|
||||
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user