-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
29 lines (22 loc) · 790 Bytes
/
app.js
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
const express = require("express");
const path = require("path");
const bodyParser = require("body-parser");
const indexRouter = require("./routes/index");
const emailRoutes = require("./routes/emailRoutes");
const app = express();
const port = 3000;
// Set view engine to EJS
app.set("view engine", "ejs");
// Define the views directory
app.set("views", path.join(__dirname, "views"));
// Serve static files from the "public" directory
app.use(express.static(path.join(__dirname, "public")));
// Middleware to parse JSON and URL-encoded data
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
// Routes
app.use("/", indexRouter);
app.use("/api", emailRoutes);
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});