Spaces:
Running
Running
Create app.js
Browse files
app.js
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const express = require('express');
|
2 |
+
const app = express();
|
3 |
+
|
4 |
+
// Inisialisasi penghitung hit
|
5 |
+
let hitCount = 0;
|
6 |
+
|
7 |
+
// Route untuk menghitung hit
|
8 |
+
app.get('/', (req, res) => {
|
9 |
+
hitCount++;
|
10 |
+
res.json({
|
11 |
+
message: 'Selamat datang di penghitung hit!',
|
12 |
+
hits: hitCount
|
13 |
+
});
|
14 |
+
});
|
15 |
+
|
16 |
+
// Mendengarkan di port 7680
|
17 |
+
const PORT = 7680;
|
18 |
+
app.listen(PORT, () => {
|
19 |
+
console.log(`Server berjalan di port ${PORT}`);
|
20 |
+
});
|