wah.moe/app/components/wah_component.rb
2025-09-21 03:09:52 +01:00

21 lines
564 B
Ruby

# frozen_string_literal: true
require "net/http"
require "json"
class WahComponent < ViewComponent::Base
def initialize(legacy:)
if legacy then
else
uri = URI.parse('https://api.tinyfox.dev/img.json?animal=wah')
req = Net::HTTP::Get.new(uri.to_s)
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) {|http|
http.request(req)
}
data = JSON.parse(res.body)
url = "https://tinyfox.dev" + data["loc"]
@wah_url = url
end
end
end