philomena/lib/philomena_web/controllers/search/reverse_controller.ex
2020-08-11 19:15:32 -04:00

22 lines
606 B
Elixir

defmodule PhilomenaWeb.Search.ReverseController do
use PhilomenaWeb, :controller
alias PhilomenaWeb.ImageReverse
plug PhilomenaWeb.ScraperCachePlug
plug PhilomenaWeb.ScraperPlug, params_key: "image", params_name: "image"
def index(conn, params) do
create(conn, params)
end
def create(conn, %{"image" => image_params}) when is_map(image_params) do
images = ImageReverse.images(image_params)
render(conn, "index.html", title: "Reverse Search", images: images)
end
def create(conn, _params) do
render(conn, "index.html", title: "Reverse Search", images: nil)
end
end