-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (28 loc) · 839 Bytes
/
index.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
console.log("Loading from NodeJs...");
const express = require('express')
const path = require('path')
const PORT = process.env.PORT || 5000
console.log("Loaded expss ...");
var app = express();
console.log("Loaded app...",app);
var http = require('http'),
fs = require('fs');
fs.readFile('./index.html', function (err, html) {
app.get('/random.text', function (req, res) {
res.send('./random.txt');
});
console.log("html-->",html);
console.log("err-->",err);
if (err) {
throw err;
}
http.createServer(function(request, response) {
response.writeHeader(200, {"Content-Type": "text/html"});
response.write(html);
response.end();
}).listen(PORT);
});
app.get('/random.text', function (req, res) {
res.send('./random.txt');
});
console.log('listening on port...');