-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
61 lines (38 loc) · 1.12 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const express = require("express");
const ejs = require("ejs");
const bodyParser = require("body-parser");
const puppeteer = require("puppeteer");
const app = express();
const scrape = require("./scraper");
// for testing!
app.use(express.static("./public"));
app.set("view engine", "ejs");
app.set("views", "./views");
// comment out the above 3 testing lines, and uncomment these next 3 lines for electron packager
// app.use(express.static("./resources/app/public"));
// app.set("view engine", "ejs");
// app.set("views", "./resources/app/views");
// Run the following line to package the app into an executable
// electron-packager ./ app-name
app.use(
bodyParser.urlencoded({
extended: true,
})
);
app.get("/", (req, res) => {
res.render("index");
});
app.post("/", async (req, res) => {
const rawSeq = await req.body.seq.replace(/\n/g, "");
const scrapeResult = await scrape(rawSeq);
res.render("result", {
targets: scrapeResult,
i: 1
});
});
app.get("/about", (req, res) => {
res.render("about");
});
app.listen(3000, () => {
console.log("Server successfully started at port 3000.");
});