added some commands
:)
This commit is contained in:
23
server.js
23
server.js
@@ -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"})
|
||||
|
||||
Reference in New Issue
Block a user