/indexer

Receives an URL from a Webpage and index h1, h2 and h3 links

Primary LanguageRubyMIT LicenseMIT

Setup

If something does not work, please let me know.

1 - Install Docker

2 - Install Docker compose

3 - Start the docker daemon

# example using the systemd
sudo systemctl start docker

4 - Clone the project

git clone https://github.com/rafaelmoraes/indexer
cd indexer

5 - Run on console

#Maybe you need to use sudo
docker-compose up -d
docker-compose exec rails bash

Now you should be inside the rails docker container

6 - Create the database

rails db:create db:migrate

7 - Run the rails server

rails s -b 0.0.0.0

8 - Open your browser and access http://localhost:3000, you should see the rails default page

Test using curl

# Create
curl -i -H "Accept: application/vnd.api+json" -H 'Content-Type:application/vnd.api+json' -X POST -d '{"data": {"type":"webpages", "attributes":{"url":"https://www.bbc.co.uk/"}}}' http://localhost:3000/webpages

# Get all
curl -i -H "Accept: application/vnd.api+json" -H 'Content-Type:application/vnd.api+json' -X GET http://localhost:3000/webpages

# Get all headers indexed from webpage ID 1
curl -i -H "Accept: application/vnd.api+json" -H 'Content-Type:application/vnd.api+json' -X GET http://localhost:3000/webpages/1/headers

# Error
curl -i -H "Accept: application/vnd.api+json" -H 'Content-Type:application/vnd.api+json' -X POST -d '{"data": {"type":"webpages", "attributes":{"url":""}}}' http://localhost:3000/webpages