24 lines
577 B
JavaScript
24 lines
577 B
JavaScript
const express = require('express');
|
|
const path = require('path');
|
|
|
|
const app = express();
|
|
const port = 3000;
|
|
|
|
// Menyajikan file statis dari folder "views"
|
|
app.use(express.static(path.join(__dirname, 'views')));
|
|
|
|
// Routing ke halaman utama
|
|
app.get('/', (req, res) => {
|
|
res.sendFile(path.join(__dirname, 'views', 'index.html'));
|
|
});
|
|
|
|
// Routing ke halaman about
|
|
app.get('/about', (req, res) => {
|
|
res.sendFile(path.join(__dirname, 'views', 'about.html'));
|
|
});
|
|
|
|
// Menjalankan server
|
|
app.listen(port, () => {
|
|
console.log(`Server berjalan di http://localhost:${port}`);
|
|
});
|