-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (29 loc) · 734 Bytes
/
index.js
File metadata and controls
33 lines (29 loc) · 734 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
const express = require('express');
const app = express();
const PORT = 3000;
/**
* const server = http.createServer((req, res) => {
*
* if (req.url === "/" && req.method === "GET") {
* res.writeHead(200, { "Content-Type": "text/html" });
* res.write("<h1>Home Page</h1>");
* res.end();
* }
*
* });
*
*/
app.get("/", (req, res) => {
res.set("Content-Type", "text/html");
// untuk mengecek apakah content-type sudah di set atau belum pada header
console.log(res.get("Content-Type"));
res.send("<h1>Home Page</h1>");
})
/**
* server.listen(PORT, () => {
* console.log(`Server is running on port ${PORT}`);
* }
*/
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});