forked from marekfoltanski/indexingapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
51 lines (38 loc) · 927 Bytes
/
index.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// index.js
/**
* Required External Modules
*/
const express = require("express");
const path = require("path");
const bodyParser = require("body-parser");
const indexingApi = require("./function");
/**
* App Variables
*/
const app = express();
const port = process.env.PORT || "8000";
/**
* App Configuration
*/
app.set("views", path.join(__dirname, "views"));
app.set("view engine", "pug");
app.use(express.static(__dirname + "/public"));
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
/**
* Routes Definitions
*/
app.get("/", (req, res) => {
res.render("index", { title: "Indexing API" });
});
app.post("/result", function (req, res) {
indexingApi.indexingApi(req.body.data, (data) => {
res.render("result", { data: data });
});
});
/**
* Server Activation
*/
app.listen(port, () => {
console.log(`Listening to requests on http://localhost:${port}`);
});