19 lines
595 B
Ruby
Executable File
19 lines
595 B
Ruby
Executable File
#! /bin/env ruby
|
|
|
|
require "sinatra"
|
|
require "json"
|
|
require "http"
|
|
require "active_support/all"
|
|
|
|
# USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36"
|
|
USER_AGENT = "MoxProx 0.1.0"
|
|
|
|
get "/deck_xml" do
|
|
deck_id = params['id']
|
|
api_url = "https://api2.moxfield.com/v3/decks/all/" + deck_id
|
|
content = HTTP.headers({"User-Agent" => USER_AGENT, 'Accept' => 'application/json'}).get(api_url)
|
|
puts content
|
|
xml_data = JSON.parse(content).to_xml(:root => :deck)
|
|
[200, {"Content-Type" => "application/xml"}, xml_data]
|
|
end
|