【发布时间】:2015-02-03 03:09:39
【问题描述】:
我在 python 中有一个服务器来处理一个 id(youtube 视频的 id),这是代码:
class MessageHandler(tornado.web.RequestHandler):
def get(self, action_id):
print "Message = " + action_id
if action_id == "id":
for ws in opened_ws:
ws.write_message("ID: " + action_id)
return render_template('js/player.js', action_id=json.dumps(action_id))
(...)
我使用返回的render_template将“action_id”传递给player.js,这是一个使用Youtube API处理电影的函数,代码是:
var PushPlayer = (function () {
var player = null;
function new_player() {
player = new YT.Player('yt-player', {
videoId: action_id,
}
});
}
(...)
使用action_id,我可以拥有youtube 视频的所有ID.. 但我不知道谁将action_id 从python 传递到javascript.. 有什么想法吗?
谢谢!
【问题讨论】:
标签: javascript python api youtube server