Skip to content

Instantly share code, notes, and snippets.

@tedma4
Created November 13, 2017 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tedma4/15e9a0591a846128db911f236a54a195 to your computer and use it in GitHub Desktop.
Save tedma4/15e9a0591a846128db911f236a54a195 to your computer and use it in GitHub Desktop.
Making HTTPS requests
class Req
require 'base64'
require 'net/http'
require 'net/https'
def request(user,pass)
token = Base64.encode64("#{user}:#{pass}").strip
uri = URI("https://example.com/list")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
# http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
request["AUTHORIZATION"] = "Bearer #{token}"
request["Content-Type"] = "application/json"
response = http.request(request)
response
end
end
Shoes.app do
stack(margin: 40) do
@login = edit_line do |e|
if @login.text.blank?
@login_value.text = "what you type in the edit box goes here"
else
@login_value.text = @login.text
end
end
@password = edit_line do |e|
if @password.text.blank?
@password_value.text = "what you type in the edit box goes here"
else
@password_value.text = @password.text
end
end
@button = button("Select The File") do
if !@login.text.blank? && !@password.text.blank?
info('button clicked!!!')
para Req.new.request(@login.text, @password.text)
else
alert("Please Enter Your login and password")
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment