-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
35 lines (26 loc) · 963 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
const express = require('express')
const app = express()
app.get('/', (req, res, next) => {
res.sendFile('/Users/sahajadlakha/Documents/DEV_ZONE/PhishingDetection/UI/index.html')
})
app.get('/checkurl',(req, res, next) => {
// Running python script
var spawnSync = require("child_process").spawnSync
var process = spawnSync('python3',["./app.py", req.query.inputurl])
var er = process.stderr.toString()
if (er) {
console.log(er)
}
result = process.stdout.toString().trim()
console.log(result)
if (result == "1") {
res.sendFile('/Users/sahajadlakha/Documents/DEV_ZONE/PhishingDetection/UI/phishy.html')
} else if (result == "0") {
res.sendFile('/Users/sahajadlakha/Documents/DEV_ZONE/PhishingDetection/UI/legit.html')
} else {
console.log('Error in result from Python script')
}
})
app.listen(3000, () => {
console.log("Server listening to http://localhost:3000/")
})