Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 1,293 Bytes
b628664 9fd8477 b628664 9fd8477 db9bd2d e590a74 9fd8477 66bfda5 db9bd2d 9fd8477 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
import { handler } from './build/handler.js';
import express from 'express';
import cron from 'node-cron';
import fetch from 'node-fetch';
import dotenv from 'dotenv';
dotenv.config();
const app = express();
// Serve your "data/assets" folder
app.use(express.static('data/assets'))
// let SvelteKit handle everything else, including serving prerendered pages and static assets
app.use(handler);
app.listen(3000, () => {
console.log('listening on port 3000');
});
cron.schedule("0 * * * *", async () => {
console.log('Scraping models')
const request = await fetch(`https://${process.env.SPACE_HOST}/api/scrap-models`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-hf-token': process.env.SECRET_HF_TOKEN
},
});
const response = await request.json();
console.info(response?.message)
});
cron.schedule("0 0 * * 1,4", async () => {
console.log('Updating models')
const request = await fetch(`http://${process.env.SPACE_HOST}/api/models`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
'x-hf-token': process.env.SECRET_HF_TOKEN
},
});
const response = await request.json();
console.info(response?.message)
});
|