forked from SamTLD/HomeWork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
22-App2.js
46 lines (33 loc) · 1.04 KB
/
22-App2.js
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
/*const http = require('http')
//using Events emiter API
const server = http.createServer()
//emit request event
//subscribe/listen/respond
server.on('request',(req,res)=>{
res.end('welcome')
})
server.listen(5001)
var http = require('http')
var fs = require('fs')
const server = http.createServer((req,res)=>{
const largeText = fs.readFileSync('./content/100000.txt', 'utf8')
res.end(largeText);
})
http.createServer(function(req,res){
const largeText = fs.readFileSync('./content/100000.txt', 'utf8')
res.end(file);
})
http.createServer(function(req,res){
const fileStream= fs.createReadStream('./content/100000.txt', 'utf8');
fileStream.on('open',()=>{
fileStream.pipe(res)
})
fileStream.on('error',(err)=>{
res.end(err)
})
})
.listen(5000)*/
/*REST API = representational state transfre => Arkitechture
http = hypertext transfer protocal =>protocal
json = javascript object Notation=> representas the structure of data
api application programing interface => DEFIEND way of communication*/