Add basic captchaserver

This commit is contained in:
HF 2021-02-04 23:56:12 +01:00
parent 0791e0a173
commit 73e400f79a

30
src/captchaserver.js Normal file
View File

@ -0,0 +1,30 @@
/*
* serving captchas
*/
import process from 'process';
import http from 'http';
import ppfunCaptcha from 'ppfun-captcha';
/*
const [
PORT,
REDIS_URL,
] = process.argv.slice(2);
*/
const PORT = 7000;
const server = http.createServer((req, res) => {
const captcha = ppfunCaptcha.create();
console.log(`Serving ${captcha.text} to ${req.headers['x-real-ip']}`);
res.writeHead(200, {
'Content-Type': 'text/html',
'Cache-Control': 'no-cache',
});
res.write(captcha.data);
res.end();
});
server.listen(port, () => {
console.log(`Captcha Server listening on port ${port}`);
});