lora-studio / server.js
enzostvs's picture
enzostvs HF staff
cron twice a week
66bfda5
raw
history blame
1.29 kB
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)
});