lora-studio / server.js
enzostvs's picture
enzostvs HF staff
acd log
8b7b802
raw
history blame
1.27 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', process.env.SPACE_HOST)
const request = await fetch(`${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 * * *", async () => {
const request = await fetch(`${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)
});