Spaces:
Paused
Paused
Update server.js
Browse files
server.js
CHANGED
|
@@ -13,10 +13,13 @@ function generateRandomHex(length) {
|
|
| 13 |
return crypto.randomBytes(length).toString("hex");
|
| 14 |
}
|
| 15 |
|
|
|
|
|
|
|
|
|
|
| 16 |
app.use("/tmp", express.static(tempDir));
|
| 17 |
|
| 18 |
app.all("/", async (req, res) => {
|
| 19 |
-
const captcha = new CaptchaGenerator({ height: 200, width: 600 })
|
| 20 |
|
| 21 |
const fileName = `temp_${generateRandomHex(8)}.png`;
|
| 22 |
const filePath = path.join(tempDir, fileName);
|
|
|
|
| 13 |
return crypto.randomBytes(length).toString("hex");
|
| 14 |
}
|
| 15 |
|
| 16 |
+
const rand = (length) =>
|
| 17 |
+
[...Array(length)].map(() => (Math.random().toString(36)[2] || '0')).join('');
|
| 18 |
+
|
| 19 |
app.use("/tmp", express.static(tempDir));
|
| 20 |
|
| 21 |
app.all("/", async (req, res) => {
|
| 22 |
+
const captcha = new CaptchaGenerator({ text: rand(6), height: 200, width: 600 })
|
| 23 |
|
| 24 |
const fileName = `temp_${generateRandomHex(8)}.png`;
|
| 25 |
const filePath = path.join(tempDir, fileName);
|