Spaces:
Running
Running
Update index.js
Browse files
index.js
CHANGED
@@ -18,6 +18,39 @@ const app = express();
|
|
18 |
const readFileAsync = promisify(fs.readFile);
|
19 |
import fetch from 'node-fetch';
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
const tempDir = path.join(os.tmpdir(), "temp");
|
22 |
const fss = fs.promises;
|
23 |
|
|
|
18 |
const readFileAsync = promisify(fs.readFile);
|
19 |
import fetch from 'node-fetch';
|
20 |
|
21 |
+
|
22 |
+
|
23 |
+
const puppeteer = require('puppeteer');
|
24 |
+
|
25 |
+
// Function to ping a website
|
26 |
+
async function pingWebsite() {
|
27 |
+
const browser = await puppeteer.launch({
|
28 |
+
headless: true,
|
29 |
+
args: ['--no-sandbox', '--disable-setuid-sandbox']
|
30 |
+
});
|
31 |
+
const page = await browser.newPage();
|
32 |
+
await page.setUserAgent("Mozilla/5.0 (Linux; Android 10; SM-G965U Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/114.0.5735.141 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/420.0.0.32.61;]");
|
33 |
+
|
34 |
+
await page.goto('https://huggingface.co/spaces/ArashiCode/api'); // Replace 'https://example.com' with the website you want to ping
|
35 |
+
await page.waitFor(30000); // Wait for 30 seconds
|
36 |
+
console.log("ping")
|
37 |
+
await browser.close();
|
38 |
+
}
|
39 |
+
|
40 |
+
// Ping website every 5 hours
|
41 |
+
async function pingEvery5Hours() {
|
42 |
+
await pingWebsite();
|
43 |
+
setInterval(async () => {
|
44 |
+
await pingWebsite();
|
45 |
+
}, 5 * 60 * 60 * 1000); // 5 hours in milliseconds
|
46 |
+
}
|
47 |
+
|
48 |
+
// Start pinging
|
49 |
+
pingEvery5Hours();
|
50 |
+
|
51 |
+
|
52 |
+
|
53 |
+
|
54 |
const tempDir = path.join(os.tmpdir(), "temp");
|
55 |
const fss = fs.promises;
|
56 |
|