chromesetting
guange 5 years ago
parent d5446c54e0
commit b352ec635e

@ -1,8 +1,12 @@
require 'net/http'
class JupytersController < ApplicationController
before_action :shixun
def open
#打开tpm - juypter接口
shixun = Shixun.find(3575)
shixun = @shixun
shixun_tomcat = edu_setting('cloud_bridge')
uri = "#{shixun_tomcat}/bridge/jupyter/get"
tpiID = "tpm#{shixun.id}"
@ -15,7 +19,7 @@ class JupytersController < ApplicationController
logger.info "test_juypter: #{res}"
render plain: "https://#{res['port']}.jupyter.educoder.net/data/workspace/myshixun_#{tpiID}/01.ipynb"
render plain: "https://#{res['port']}.jupyter.educoder.net/notebooks/data/workspace/myshixun_#{tpiID}/01.ipynb"
end
def open1
@ -38,6 +42,39 @@ class JupytersController < ApplicationController
def test
render plain: 'test'
end
def save()
# 保存01.ipy
author_name = current_user.real_name
author_email = current_user.git_mail
message = "User submitted"
src_url = URI("https://47519.jupyter.educoder.net/nbconvert/notebook/data/workspace/myshixun_tpm3575/01.ipynb?download=true")
response = Net::HTTP.get_response(src_url)
if response.code != 200
raise("获取文件内容失败:#{response.code}")
end
content = response.body
c = GitService.update_file(repo_path: @shixun.repo_path,
file_path: "01.ipynb",
message: message,
content: content,
author_name: author_name,
author_email: author_email)
render plain: 'save: #{c.size}'
end
private
def shixun
@shixun = Shixun.find(3575)
end
end

@ -14,6 +14,7 @@ Rails.application.routes.draw do
get :open
get :open1
get :test
get :save
end
end

Loading…
Cancel
Save