-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
38 lines (31 loc) · 1008 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
30
31
32
33
34
35
36
37
38
const express = require("express");
const bodyParser = require("body-parser");
const path = require("path");
const _ = require("lodash");
const app = express();
app.set("view engine", "ejs");
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static("public"));
app.get("/", (req, res) => res.sendFile(__dirname + "/index.html"));
app.post("/", (req, res) => {
var username = _.capitalize(req.body.userName);
var crushname = _.capitalize(req.body.crushName);
var firstmeet = req.body.firstMeet;
var thingslike = req.body.thingsLike;
var usergender = req.body.gender;
var randomNo = Math.floor(Math.random() * 100) + 1;
var randomValue = `${randomNo * 1} % `;
res.render("index", {
USERNAME: username,
CRUSHNAME: crushname,
RANDOMVALUE: randomValue,
USERGENDER: usergender,
});
});
let port = process.env.PORT;
if (port == null || port == "") {
port = 3000;
}
app.listen(port, () =>
console.log(`Server has started listening on port ${port}!`)
);