svg-captcha-npmzw
Version:
仿写 svg-captcha 验证码
42 lines (31 loc) • 897 B
Markdown
# 图片验证码
仿写 svg-captcha 验证码
## 下载依赖
`npm i svg-captcha-npmzw`
## 导入依赖
`const captcha = require("svg-captcha-npmzw");`
## 本地运行查看效果
`node test.js`
## 具体使用示例
```
// 一、导入官方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");
});
```
## 查看源码:
[https://unpkg.com/browse/svg-captcha-npmzw/](https://unpkg.com/browse/svg-captcha-npmzw/)