UNPKG

svg-captcha-npmzw

Version:

仿写 svg-captcha 验证码

21 lines (18 loc) 552 B
// 一、导入官方http模块 const http = require("http"); // 二、导入验证码模块 const captcha = require("./index"); // const captcha = require("svg-captcha-npmzw"); // 三、创建服务器 const server = http.createServer((req, res) => { // 1.设置请求头 res.setHeader("content-type", "text/html;charset=utf-8"); // 2.调用方法 let temp = captcha.create(); // 3.服务器响应 res.end(temp.data); }); // 四、监听端口 server.listen(3004, () => { console.log("服务启动成功,http://localhost:3004"); });