feat: load website html route
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user