-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
26 lines (20 loc) · 990 Bytes
/
index.js
File metadata and controls
26 lines (20 loc) · 990 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
// Import required modules
const express = require("express"); // Express framework for handling HTTP requests
const path = require("path"); // Node.js module for working with file and directory paths
// Create an instance of an Express application
const app = express();
// Define the port number for the server to listen on
const PORT = 3000;
// Set the view engine to EJS (Embedded JavaScript)
// This allows us to render dynamic HTML templates using EJS
app.set("view engine", "ejs");
// Import the routes file from the "routes" directory
// This keeps our route logic organized in a separate file
const routes = require("./routes/routes");
// Use the imported routes for handling requests
// The "/" means that these routes apply to the root of the site
app.use("/", routes);
// Start the server and listen for incoming requests on the defined port
app.listen(PORT, () => {
console.log(`Server running on http://localhost:${PORT}`); // Log a message when the server starts
});