Skip to content
Merged

. #14

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
data
node_modules
static/*.upload.*
10 changes: 6 additions & 4 deletions run.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ const requestListener = function (req, res) {
intcode = "./data/keys/" + intcode
fs.writeFileSync(intcode,body)

fs.readFile(intcode, 'utf8', function(err, data){

/*fs.readFile(intcode, 'utf8', function(err, data){

if (err){ throw err; }
var lines = data.split('\n')
var type = lines[2]
Expand All @@ -107,10 +109,10 @@ const requestListener = function (req, res) {
lines = lines.join('\n')
//console.log(lines)
/* fs.writeFileSync(intcode, lines); */
fs.writeFileSync(intcode+".type",type)
//fs.writeFileSync(intcode+".type",type)
console.log("File uploaded to "+"\x1b[32m"+intcode.replace("./data/keys/","")+"\x1b[37m" +" Type: " + type)

});
/*})*/;


})
Expand All @@ -126,7 +128,7 @@ console.log("File uploaded to "+"\x1b[32m"+intcode.replace("./data/keys/","")+"\
res.end(data);
});

} else if(String(req.url).startsWith("/download/")){
} else if(String(req.url).startsWith("/download/") && false){
//log(String(req.url).replace("/download/",""))
let pathh = (String(req.url).replace("/download/",""))
pathh = "./data/keys/" + pathh + ".type"
Expand Down
7 changes: 4 additions & 3 deletions static/start.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
window.onload = function(){
let codeplace = document.getElementById("code")

//let upbutton = document.getElementById("upb")
let upbutton = document.getElementById("upb")

let dbutton = document.getElementById("downb")

console.log("Script included.")
//upbutton.onclick = function(){
upbutton.onclick = function(){

//}
}
dbutton.onclick =function(){
window.location = "/download/"+codeplace.value
}


}
6 changes: 1 addition & 5 deletions templates/start.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@
<div height = 5%></div>

<input type="text" name="Code" id = "code" size="15"> <button id = "downb">Download file</button></br>
<form action="/upload" method="post" enctype="multipart/form-data">
<label for="upload">File:</label>
<input type="file" id="upload"><br/>
<input type="submit" name="submit" value="Upload">
</form>
<button id = "upb">Upload file</button>
<script src = "start.js"></script>


Expand Down