1.0.1 • Published 2 years ago

jsonzheng-captcha.test v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

下载

npm i svg-captcha -S

引用

const svgCaptcha = require('svg-captcha')

使用

const server = http.createServer((req,res) => {
     if(req.url === "/captcha") {
          const captcha = svgCaptcha.create({
               size: 4,
               fontSize: 45,
               noise: 1,
               width: 120,
               height: 36,
               color: true,
               background: "#ccc",
          });
          // res.setHeader("content-type","image/svg+html");
          res.setHeader("content-type","text/html,charset=utf-8");
          res.end(captcha.data);
     } else {
          res.end("404")
     }
})