fix: repeated result when resubmit
This commit is contained in:
parent
e6d0ece5bb
commit
9ffb9e334c
|
@ -4,10 +4,6 @@ const swipl = require('swipl');
|
||||||
|
|
||||||
const app = express()
|
const app = express()
|
||||||
const PORT = 3000
|
const PORT = 3000
|
||||||
swipl.call('assert(ip("_", "_"))');
|
|
||||||
swipl.call('assert(nip("_", "_"))');
|
|
||||||
swipl.call('assert(all("_", "_"))');
|
|
||||||
swipl.call('assert((allowed_to_send_email(Domain, IP) :- (ip(Domain, IP)), once(\\+ all(Domain, "-"); \\+ nip(Domain, IP))))');
|
|
||||||
|
|
||||||
const spf = (req, res) => {
|
const spf = (req, res) => {
|
||||||
try {
|
try {
|
||||||
|
@ -40,6 +36,10 @@ const spf = (req, res) => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
return res.status(err.code).send(err.message)
|
return res.status(err.code).send(err.message)
|
||||||
}
|
}
|
||||||
|
swipl.call('assert(ip("_", "_"))');
|
||||||
|
swipl.call('assert(nip("_", "_"))');
|
||||||
|
swipl.call('assert(all("_", "_"))');
|
||||||
|
swipl.call('assert((allowed_to_send_email(Domain, IP) :- (ip(Domain, IP)), once(\\+ all(Domain, "-"); \\+ nip(Domain, IP))))');
|
||||||
const query = new swipl.Query(`allowed_to_send_email(${domain}, IP)`);
|
const query = new swipl.Query(`allowed_to_send_email(${domain}, IP)`);
|
||||||
let ret = null;
|
let ret = null;
|
||||||
let result = []
|
let result = []
|
||||||
|
@ -48,6 +48,8 @@ const spf = (req, res) => {
|
||||||
result.push(`${ret.IP}`);
|
result.push(`${ret.IP}`);
|
||||||
}
|
}
|
||||||
query.close();
|
query.close();
|
||||||
|
swipl.cleanup()
|
||||||
|
swipl.initialise()
|
||||||
return res.status(200).send(result)
|
return res.status(200).send(result)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user