File size: 1,085 Bytes
3c1719f
7224f6f
3c1719f
 
7224f6f
3c1719f
 
 
 
 
7224f6f
6f47f93
 
 
daa94ed
3c1719f
 
 
7224f6f
3c1719f
6fd0ead
3c1719f
 
 
6fd0ead
3c1719f
 
 
 
6fd0ead
3c1719f
 
 
 
6fd0ead
3c1719f
 
 
6fd0ead
3c1719f
 
 
7224f6f
3c1719f
 
7224f6f
3c1719f
 
 
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
// const http = require('http');

// const hostname = process.env.HOST || '0.0.0.0';
// const port = process.env.PORT || 7860;

// const server = http.createServer((req, res) => {
//   res.statusCode = 200;
//   res.setHeader('Content-Type', 'text/plain');
//   res.end('Hello World');
// });

// server.listen(port, hostname, () => {
//   console.log(`Server running at http://${hostname}:${port}/`);
// });

var express = require("express");
var app = express();
var router = express.Router();

var path = __dirname + '/views/';

// Constants
const PORT = process.env.PORT || 7860;
const HOST = '0.0.0.0';

router.use(function (req,res,next) {
  console.log("/" + req.method);
  next();
});

// Hello world api
router.get("/",function(req,res){
  res.send("Hello world!");
});

router.get("/home",function(req,res){
  res.sendFile(path + "index.html");
});

router.get("/sharks",function(req,res){
  res.sendFile(path + "sharks.html");
});

app.use(express.static(path));
app.use("/", router);

app.listen(PORT, function () {
  console.log(`Example app listening on port ${PORT}`)
})