feat: load website html route

This commit is contained in:
karishmas6
2024-04-21 19:51:19 +05:30
parent f33e70af17
commit ed5dd602ac

View File

@@ -1,6 +1,7 @@
import Fastify from 'fastify'
import cors from '@fastify/cors'
import scrapeData from './scraper';
import loadWebsite from './load';
const fastify = Fastify();
@@ -15,6 +16,17 @@ fastify.get('/', async (request, reply) => {
reply.send('Vroom Vroom Vroom');
});
fastify.post('/load-website', async (request, reply) => {
const { url } = request.body;
try {
const response = await loadWebsite(url);
reply.send(response);
console.log('Response is::', response)
} catch (error) {
reply.status(500).send({ error: error });
}
});
fastify.post('/scrape', async (request, reply) => {
const { url, selectors } = request.body;
try {