philomena/lib/philomena_web/controllers/search/reverse_controller.ex

19 lines
514 B
Elixir
Raw Normal View History

2019-11-29 01:11:05 +01:00
defmodule PhilomenaWeb.Search.ReverseController do
use PhilomenaWeb, :controller
2019-12-04 01:50:23 +01:00
alias PhilomenaWeb.ImageReverse
2019-11-29 01:11:05 +01:00
plug PhilomenaWeb.ScraperPlug, [params_key: "image", params_name: "image"] when action in [:create]
def index(conn, _params) do
2019-12-16 20:24:38 +01:00
render(conn, "index.html", title: "Reverse Search", images: nil)
2019-11-29 01:11:05 +01:00
end
def create(conn, %{"image" => image_params}) do
2019-12-04 01:50:23 +01:00
images = ImageReverse.images(image_params)
2019-11-29 01:11:05 +01:00
conn
2019-12-16 20:24:38 +01:00
|> render("index.html", title: "Reverse Search", images: images)
2019-11-29 01:11:05 +01:00
end
2019-12-16 20:24:38 +01:00
end