Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'sinatra'
- require 'json'
- require 'net/https'
- USER = "KhanBugz"
- PASS = ""
- def gh_http
- http = Net::HTTP.new("api.github.com", 443)
- http.use_ssl = true
- http
- end
- def gh_post(path, data)
- req = Net::HTTP::Post.new(path)
- req.basic_auth USER, PASS
- req.content_type = "application/json"
- req.body = data
- gh_http.request req
- end
- get "/file_exercise_tester_bug" do
- issue = {
- :title => params[:title],
- :body => params[:body],
- :labels => [params[:label]],
- }
- callback = params[:callback].gsub(/[^a-z0-9_-]/i, "")
- resp = gh_post("/repos/Khan/khan-exercises/issues?callback=#{callback}", issue.to_json)
- status resp.code
- content_type "application/javascript"
- resp.body
- end
- get "/file_exercise_tester_bug_comment" do
- issue = {
- :body => params[:body]
- }
- id = params[:id].to_i
- callback = params[:callback].gsub(/[^a-z0-9_-]/i, "")
- resp = gh_post("/repos/Khan/khan-exercises/issues/#{id}/comments?callback=#{callback}", issue.to_json)
- status resp.code
- content_type "application/javascript"
- resp.body
- end
Add Comment
Please, Sign In to add comment