Last active
September 3, 2018 16:00
-
-
Save mscoutermarsh/4fef956808a2a73b088f8e4c827e6519 to your computer and use it in GitHub Desktop.
Ruby - convert html/css to an image
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 "httparty" | |
# Retrieve your user id and api key from the Dashboard https://htmlcsstoimage.com/dashboard | |
auth = { username: 'user_id', password: 'api_key' } | |
html = "<div class='ping'>Pong ✅</div>" | |
css = ".ping { padding: 20px; font-family: 'sans-serif'; }" | |
image = HTTParty.post("https://hcti.io/v1/image", | |
body: { html: html, css: css }, | |
basic_auth: auth) | |
# => {"url"=>"https://hcti.io/v1/image/bde7d5bf-f7bb-49d9-b931-74e5512b8738"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment