added some commands

:)
This commit is contained in:
valentijn
2024-01-18 14:41:17 +01:00
parent 9c0e165b33
commit e4be64245b
4 changed files with 37 additions and 9 deletions

View File

@@ -8,6 +8,19 @@ app.use(express.static("httpdocs/public"))
const documentRoot = `${__dirname}/httpdocs`
let fileSystem = {
"guest": {
"type": "directory",
"contents": {
"file.txt": {
"type": "file",
"content": "This is the text in the file <br> and I don't use \n to simulate a line break"
}
}
}
}
app.get('/', (req, res) => {
res.sendFile(documentRoot+"/index.html")
@@ -21,8 +34,14 @@ app.get("/execute", (req, res)=> {
console.log(`Executed Command: ${formatted_command}`);
if (formatted_command.startsWith("cd")){
commands.cd(req, res);
if (formatted_command.startsWith("ls")){
commands.ls(req, res);
}
else if (formatted_command.startsWith("whoami")){
commands.whoami(req, res);
}
else if (formatted_command.startsWith("pwd")){
commands.pwd(req, res, currentDir);
}
else {
res.json({"response": "invalid command"})