-
Notifications
You must be signed in to change notification settings - Fork 0
/
Notes
115 lines (86 loc) · 3.14 KB
/
Notes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// console.log("Server file is runner ");
// const os = require("os")
// const fs = require("fs");
// const _ = require("lodash");
// const Notes = require("./Notes");
// const user = os.userInfo();
// console.log(user);
// fs.appendFile("great.txt" , "Hello Mohit Kumar" + user.username , () => {})
// const data = ["mohit","mohit", 1,2,1,2,3,4,2,3, "mohit"]
// const filter = _.uniq(data)
// console.log(filter);
// var http = require('http');
// http.createServer(function (req, res) {
// res.writeHead(200, {'Content-Type': 'text/html'});
// res.write('<form action="fileupload" method="post" enctype="multipart/form-data">');
// res.write('<input type="file" name="filetoupload"><br>');
// res.write('<input type="submit">');
// res.write('</form>');
// return res.end();
// }).listen(8080);
// var http = require('http');
// var formidable = require('formidable');
// http.createServer(function (req, res) {
// if (req.url == '/fileupload') {
// var form = new formidable.IncomingForm();
// form.parse(req, function (err, fields, files) {
// res.write('File uploaded');
// res.end();
// });
// } else {
// res.writeHead(200, {'Content-Type': 'text/html'});
// res.write('<form action="fileupload" method="post" enctype="multipart/form-data">');
// res.write('<input type="file" name="filetoupload"><br>');
// res.write('<input type="submit">');
// res.write('</form>');
// return res.end();
// }
// }).listen(8080);
/*var http = require('http');
var formidable = require('formidable');
var fs = require('fs');
http.createServer(function (req, res) {
if (req.url == '/fileupload') {
var form = new formidable.IncomingForm();
form.parse(req, function (err, fields, files) {
var oldpath = files.filetoupload.filepath;
var newpath = 'C:/Users/Your Name/' + files.filetoupload.originalFilename;
fs.rename(oldpath, newpath, function (err) {
if (err) throw err;
res.write('File uploaded and moved!');
res.end();
});
});
} else {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write('<form action="fileupload" method="post" enctype="multipart/form-data">');
res.write('<input type="file" name="filetoupload"><br>');
res.write('<input type="submit">');
res.write('</form>');
return res.end();
}
}).listen(8080);*/
// var nodemailer = require('nodemailer');
// var transporter = nodemailer.createTransport({
// service: 'gmail',
// auth: {
// user: 'youremail@gmail.com',
// pass: 'yourpassword'
// }
// });
// var mailOptions = {
// from: 'youremail@gmail.com',
// to: 'myfriend@yahoo.com',
// subject: 'Sending Email using Node.js',
// text: 'That was easy!'
// };
// transporter.sendMail(mailOptions, function(error, info){
// if (error) {
// console.log(error);
// } else {
// console.log('Email sent: ' + info.response);
// }
// });
// const jsondata = '{"name": "Mohit" , "age": 30 , "city": "Ghaziabad"}'
// const obj = JSON.parse(jsondata);
// console.log(obj.age);