老师测试代码base64加密,

返回值json取值有问题
This commit is contained in:
sw 2015-07-31 16:59:30 +08:00
parent 782f7b074e
commit d6fe9939f6
1 changed files with 4 additions and 3 deletions

View File

@ -1,6 +1,7 @@
class HomeworkCommonController < ApplicationController
require 'net/http'
require 'json'
require "base64"
layout "base_courses"
before_filter :find_course, :only => [:index,:new,:create,:next_step]
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy]
@ -353,7 +354,7 @@ class HomeworkCommonController < ApplicationController
end
def programing_test
test = {language:params[:language],src:params[:src],input:[params[:input]],output:[params[:output]]}
test = {language:params[:language],src:Base64.encode64(params[:src]),input:[params[:input]],output:[params[:output]]}
@index = params[:index]
uri = URI('http://192.168.80.21:8080/api/realtime.json')
body = test.to_json
@ -364,8 +365,8 @@ class HomeworkCommonController < ApplicationController
client.request(request)
end
result = JSON.parse(res.body)
result[:results].each do |re|
@result = re[:status]
result["results"].each do |re|
@result = re["status"]
end
end