atikur-rabbi commited on
Commit
3c1719f
1 Parent(s): 6fd0ead
Files changed (1) hide show
  1. app.js +34 -34
app.js CHANGED
@@ -1,49 +1,49 @@
1
- const http = require('http');
2
 
3
- const hostname = process.env.HOST || '0.0.0.0';
4
- const port = process.env.PORT || 7860;
5
 
6
- const server = http.createServer((req, res) => {
7
- res.statusCode = 200;
8
- res.setHeader('Content-Type', 'text/plain');
9
- res.end('Hello World');
10
- });
11
 
12
  server.listen(port, hostname, () => {
13
  console.log(`Server running at http://${hostname}:${port}/`);
14
  });
15
 
16
- // var express = require("express");
17
- // var app = express();
18
- // var router = express.Router();
19
 
20
- // var path = __dirname + '/views/';
21
 
22
- // // Constants
23
- // const PORT = 3000;
24
- // const HOST = '0.0.0.0';
25
 
26
- // router.use(function (req,res,next) {
27
- // console.log("/" + req.method);
28
- // next();
29
- // });
30
 
31
- // // Hello world api
32
- // router.get("/",function(req,res){
33
- // res.send("Hello world!");
34
- // });
35
 
36
- // router.get("/home",function(req,res){
37
- // res.sendFile(path + "index.html");
38
- // });
39
 
40
- // router.get("/sharks",function(req,res){
41
- // res.sendFile(path + "sharks.html");
42
- // });
43
 
44
- // app.use(express.static(path));
45
- // app.use("/", router);
46
 
47
- // app.listen(PORT, function () {
48
- // console.log(`Example app listening on port ${PORT}`)
49
- // })
 
1
+ // const http = require('http');
2
 
3
+ // const hostname = process.env.HOST || '0.0.0.0';
4
+ // const port = process.env.PORT || 7860;
5
 
6
+ // const server = http.createServer((req, res) => {
7
+ // res.statusCode = 200;
8
+ // res.setHeader('Content-Type', 'text/plain');
9
+ // res.end('Hello World');
10
+ // });
11
 
12
  server.listen(port, hostname, () => {
13
  console.log(`Server running at http://${hostname}:${port}/`);
14
  });
15
 
16
+ var express = require("express");
17
+ var app = express();
18
+ var router = express.Router();
19
 
20
+ var path = __dirname + '/views/';
21
 
22
+ // Constants
23
+ const PORT = process.env.PORT || 7860;
24
+ const HOST = '0.0.0.0';
25
 
26
+ router.use(function (req,res,next) {
27
+ console.log("/" + req.method);
28
+ next();
29
+ });
30
 
31
+ // Hello world api
32
+ router.get("/",function(req,res){
33
+ res.send("Hello world!");
34
+ });
35
 
36
+ router.get("/home",function(req,res){
37
+ res.sendFile(path + "index.html");
38
+ });
39
 
40
+ router.get("/sharks",function(req,res){
41
+ res.sendFile(path + "sharks.html");
42
+ });
43
 
44
+ app.use(express.static(path));
45
+ app.use("/", router);
46
 
47
+ app.listen(PORT, function () {
48
+ console.log(`Example app listening on port ${PORT}`)
49
+ })