diff --git a/harmandeep-singh/day 1/index.html b/harmandeep-singh/day 1/index.html new file mode 100644 index 00000000..8e648ac8 --- /dev/null +++ b/harmandeep-singh/day 1/index.html @@ -0,0 +1,56 @@ + + + +
+ + + +This is a paragraph.
+ + + \ No newline at end of file diff --git a/harmandeep-singh/day 3/Files/demo.txt b/harmandeep-singh/day 3/Files/demo.txt new file mode 100644 index 00000000..69c4042e --- /dev/null +++ b/harmandeep-singh/day 3/Files/demo.txt @@ -0,0 +1,2 @@ +Hello world How are you? +This is i++ bootcamp. diff --git a/harmandeep-singh/day 3/fsCreateFile.js b/harmandeep-singh/day 3/fsCreateFile.js new file mode 100644 index 00000000..fa00b05f --- /dev/null +++ b/harmandeep-singh/day 3/fsCreateFile.js @@ -0,0 +1,20 @@ +var fs = require('fs'); + +fs.appendFile('newfile.txt', 'Hello World!', function (err) { + if (err) throw err; + console.log('Saved!'); +}); + +fs.writeFile('newfile1.txt', 'Hello World!', function (err) { + if (err) throw err; + console.log('Saved!'); +}); + +fs.open('newfile2.txt', 'w', function (err, file) { + if (err) return err; + console.log('File opened successfully.'); + fs.writeFile(file, 'New data added', function (err) { + if (err) throw err; + console.log('Data written successfully.'); + }); +}) diff --git a/harmandeep-singh/day 3/fsDeleteFile.js b/harmandeep-singh/day 3/fsDeleteFile.js new file mode 100644 index 00000000..47337b98 --- /dev/null +++ b/harmandeep-singh/day 3/fsDeleteFile.js @@ -0,0 +1,15 @@ +var fs = require('fs'); + +fs.open('dummyFile.txt', 'w', function (err, file) { + if (err) { + throw err; + } + console.log('File opened successfully.'); +}); + +fs.unlink('dummyFile.txt', function (err) { + if (err) { + throw err; + } + console.log('File deleted successfully.'); +}); \ No newline at end of file diff --git a/harmandeep-singh/day 3/fsReadFile.js b/harmandeep-singh/day 3/fsReadFile.js new file mode 100644 index 00000000..a6b2a9b8 --- /dev/null +++ b/harmandeep-singh/day 3/fsReadFile.js @@ -0,0 +1,13 @@ +var http = require('http'); +var fs = require('fs'); + +http.createServer(function (req, res) { + res.writeHead(200, { 'Content-Type': 'text/html' }); + fs.readFile('./Files/demo.html', function (err, data) { + if (err) { + throw err; + } + res.write(data); + res.end(); + }) +}).listen(8080); \ No newline at end of file diff --git a/harmandeep-singh/day 3/fsUpdateFile.js b/harmandeep-singh/day 3/fsUpdateFile.js new file mode 100644 index 00000000..2f57dd74 --- /dev/null +++ b/harmandeep-singh/day 3/fsUpdateFile.js @@ -0,0 +1,6 @@ +var fs = require('fs'); + +fs.appendFile('./Files/demo.txt', 'This is i++ bootcamp.\n', function (err) { + if (err) throw err; + console.log('Updated!'); +}); \ No newline at end of file diff --git a/harmandeep-singh/day 3/serverTest.js b/harmandeep-singh/day 3/serverTest.js new file mode 100644 index 00000000..9f5084b7 --- /dev/null +++ b/harmandeep-singh/day 3/serverTest.js @@ -0,0 +1,7 @@ +var http = require('http'); + +http.createServer(function (req, res) { + res.writeHead(200, { 'Content-Type': 'text/html' }); + res.write('