-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
42 lines (32 loc) · 840 Bytes
/
index.js
File metadata and controls
42 lines (32 loc) · 840 Bytes
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
// const http = require('http');
const express = require('express');
const app = express();
const fs = require('fs');
const port = 5000;
app.use(express.json());
app.use((req, res, next)=> {
console.log('Request Received');
next();
});
app.get('/', (req, res)=>{
res.send('Hello Express!');
});
app.get('/hai', (req, res) => {
res.send('Hello World and Hai')
});
app.get('/write', (req, res)=> {
fs.writeFile('file.txt', 'Hello World Siva!', ()=>{
res.send('File Writted successfully');
});
});
app.get('/read', (req, res)=> {
fs.readFile('file.txt', 'utf8', (err, data)=>{
res.send(data);
});
});
// http.createServer((req, res)=>{
// res.write('Hello World Http');
// }).listen(port);
app.listen(port, () => {
console.log(`Local Node App Listening on port ${port}`)
});