-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c92bb4
commit 2adcd70
Showing
58 changed files
with
14,138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
|
||
const {add , multiply} = require("./calFun.js") | ||
let result = multiply(2, 3); | ||
console.log(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
function add(a, b) { | ||
return a + b; | ||
} | ||
|
||
function multiply(a, b) { | ||
return a * b; | ||
} | ||
|
||
|
||
export default {add , multiply} // esm | ||
|
||
// module.exports = { multiply, add }; //cjs | ||
|
||
|
||
// setTimeout(() => { | ||
// console.log(module) | ||
// } , 1000) | ||
|
||
// console.log(module) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// console.log("kya hal hai bhai ke") | ||
|
||
// console.log(process.env) | ||
|
||
// let num1 = process.argv[2]; | ||
// let num2 = process.argv[3]; | ||
|
||
// console.log(Number(num1) + Number(num2)) | ||
|
||
// console.log(process.argv1) | ||
|
||
// console.log("hello clg") | ||
// process.stdout.write("hello process \n") | ||
// process.stdout.write("hello process") | ||
|
||
// console.log("hello") | ||
|
||
// process.exit(1) | ||
|
||
// console.log("hello 2") | ||
|
||
// console.log(__dirname) | ||
// console.log(__filename); | ||
|
||
// const { add } = require("./calFun.mjs"); | ||
|
||
// console.log(addFun) | ||
|
||
import add from "./calFun.js" | ||
|
||
// console.log(add) | ||
|
||
let result = add.add(4, 5); | ||
console.log(result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"type": "module" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
hello ji | ||
hello ji | ||
hello ji |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
const fs = require("fs"); | ||
const os = require("os") | ||
|
||
// console.log(__dirname +"/abc.txt") | ||
// console.log(__dirname +"abc.txt") | ||
// const res = fs.writeFileSync(__dirname +"/abc.txt" , "hello sir ") | ||
// const res = fs.writeFileSync(`${__dirname}/abc.txt` , "hello sir ji ") | ||
|
||
// fs.writeFile(`${__dirname}/abc.txt` , "hello sir ji " ,function (err){ | ||
// if (err) throw err; | ||
// console.log('The file has been saved!'); | ||
// }) | ||
|
||
// console.log(fs) | ||
|
||
// console.log("1") | ||
// const data = "a".repeat(500 * 1024 *1024) | ||
// let data2 = fs.writeFileSync("abc.txt" , data) | ||
// // console.log(data) | ||
// console.log("2") | ||
|
||
// console.log("1"); | ||
// const data = "a".repeat(500 * 1024 * 1024); | ||
// fs.writeFile("abc.txt", data, (err) => { | ||
// if (err) { | ||
// console.log(err); | ||
// } else { | ||
// console.log("manla done hai"); | ||
// } | ||
// }); | ||
|
||
// console.log("2"); | ||
|
||
// console.log("1") | ||
// fs.readFile("abc.txt" , "utf-8" , (err, data) => { | ||
// if(err) throw err; | ||
// else { | ||
// console.log(data) | ||
// } | ||
// }) | ||
|
||
// console.log("2") | ||
|
||
// fs.unlink("hello.js") //delete file | ||
|
||
// fs.appendFile("abc.txt", "hello ji \n" , (err) => { | ||
// if(err) throw err; | ||
// console.log("done") | ||
// }) | ||
|
||
// fs.copyFile("abc.txt" ,"xyz.txt" ) | ||
|
||
// fs.mkdir("hello/anotherfile.js", {recursive : true} ,(err, path) => { | ||
// if (err) throw err; | ||
// else { | ||
// console.log(path); | ||
// } | ||
// }); | ||
|
||
// fs.rm("hello" , {recursive : true}) | ||
|
||
// console.log(__dirname) | ||
// console.log(__dirname.replace("lec 69", "lec 68")) | ||
|
||
// fs.readdir(__dirname.replace("lec 69", "lec 68"), {encoding : "utf-8" ,recursive :true }, (err, file) => { | ||
// if (err) throw err; | ||
// else console.log(file); | ||
|
||
// }); | ||
|
||
|
||
// const rezs = fs.readdir("ffg" , { withFileTypes : true}, (err, file) => { | ||
|
||
// console.log(file) | ||
// }) | ||
|
||
|
||
|
||
|
||
// fs.rename("abc.txt", "ABC.txt") | ||
|
||
// const res = fs.readdirSync(__dirname.replace("lec 69", "lec 68") , {withFileTypes :true}) | ||
// console.log(res) | ||
|
||
// console.log(os.cpus().length) | ||
// console.log(os.arch()) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
hello ji | ||
hello ji | ||
hello ji |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body style="background-color: aquamarine;"> | ||
<h1 style="text-align: center ; margin: 20px;">[path]</h1> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const http = require("http"); | ||
const fs = require("fs"); | ||
|
||
const server = http.createServer(function (req, res) { | ||
let filePath = __dirname + "/index.html"; | ||
|
||
// console.log(req.url) | ||
|
||
if (req.url == "/" || req.url == "/about"|| req.url == "/contactus") { | ||
let path = req.url.split("/")[1].toUpperCase(); | ||
console.log(req.method) | ||
fs.readFile(filePath, { encoding: "utf-8" }, (err, data) => { | ||
if (err) { | ||
throw new Error("Not found"); | ||
} else { | ||
data = data.replace("[path]" , path == "" ? "Code thread" : path) | ||
res.end(data); | ||
} | ||
}); | ||
} else { | ||
return res.end(JSON.stringify({ message: "not found" })); | ||
} | ||
}); | ||
|
||
server.listen(3000, () => { | ||
console.log("server started"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body style="background-color: aquamarine;"> | ||
<h1 style="text-align: center ; margin: 20px; text-transform: capitalize;">[path]</h1> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
const express = require("express"); | ||
const app = express(); | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
|
||
// app.METHOD(path , handler) | ||
|
||
function dynamicData(req, res, route) { | ||
fs.readFile(__dirname + "/index.html", { encoding: "utf-8" }, (err, data) => { | ||
if (err) { | ||
throw new Error("Not found"); | ||
} else { | ||
data = data.replace("[path]", route == "" ? "Code thread" : route); | ||
res.send(data); | ||
} | ||
}); | ||
} | ||
|
||
// app.get("/", (request, response) => { | ||
// // console.log("hello"); | ||
// // response.json({ message: "hello ji" }); | ||
// dynamicData(request, response, ""); | ||
// }); | ||
|
||
// app.get("/contactus", (request, response) => { | ||
// dynamicData(request, response, "contactus"); | ||
// }); | ||
|
||
// app.get("/about", (request, response) => { | ||
// dynamicData(request, response, "about"); | ||
// }); | ||
|
||
app.get([ "/" , "/about" , "/contactus"], (request, response) => { | ||
let path = request.url.split("/")[1] | ||
fs.readFile(__dirname + "/index.html", { encoding: "utf-8" }, (err, data) => { | ||
if (err) { | ||
throw new Error("Not found"); | ||
} else { | ||
data = data.replace("[path]" , path == "" ? "Code thread" : path) | ||
response.send(data); | ||
} | ||
}) | ||
}); | ||
|
||
// app.use() | ||
|
||
// app.post("/", (req, res) => { | ||
// res.send("hello"); | ||
// }); | ||
|
||
// app.put("/user", (req, res) => { | ||
// res.send("Got a PUT request at /user"); | ||
// }); | ||
|
||
// app.delete("/user", (req, res) => { | ||
// res.send("Got a DELETE request at /user"); | ||
// }); | ||
|
||
app.listen(3000, () => { | ||
console.log("chl gaya bhaiye server"); | ||
}); |
Oops, something went wrong.