Created
August 26, 2023 07:16
-
-
Save patatepartie/4fe7bfb9606508fa6ab1b08b80412411 to your computer and use it in GitHub Desktop.
Using Chessputzer's online instance as an API to generate a FEN from an image of a chessboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'faraday' | |
conn = Faraday.new('https://www.ocf.berkeley.edu') do |f| | |
f.request :multipart | |
f.request :url_encoded | |
f.adapter :net_http # This is what ended up making it work | |
end | |
res = diagram.open do |file| | |
payload = { :file => Faraday::UploadIO.new(file, 'image/png') } | |
conn.post('/~abhishek/putz/run.fcgi/upload', payload) | |
end | |
html_res = Nokogiri::HTML(res.body) | |
fen = html_res.css("p.boxed").first.text.split("\n").first.split(":").second.strip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment