-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
33 lines (23 loc) · 786 Bytes
/
server.js
File metadata and controls
33 lines (23 loc) · 786 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
import dotenv from "dotenv";
dotenv.config();
import express from "express";
import bodyParser from "body-parser";
import path from "path";
import cors from "cors";
import imageRoute from "./routes/image-route.js";
const __dirname = path.resolve();
const app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, "public")));
app.use(cors());
// Image Route
app.use("/api/v1/image", imageRoute);
app.get("/", (request, response) => {
response.sendFile(path.join(__dirname, "public/index.html"));
});
app.get("*", (request, response) => {
response.sendFile(path.join(__dirname, "public/index.html"));
});
app.listen(process.env.PORT, () => {
console.log(`Server Listening From PORT ${process.env.PORT}`);
});