【发布时间】:2019-06-11 16:46:08
【问题描述】:
我很难将自定义外部 JS 文件导入 Google Colab。我使用 html + js,遵循以下工作流程:
1 / 进口
from IPython.display import HTML, SVG
from IPython.core.magic import register_cell_magic
2 / 挂载驱动器
from google.colab import drive
drive.mount('/content/drive')
3/html
@register_cell_magic
def dojs(line, src):
return HTML(f"""
<canvas id="renderCanvas" touch-action="none" width="1280px" height="720px"></canvas>
<script src="content/drive/My Drive/Colab Notebooks/files/testJavascript.js"></script>
<script>
{src}
</script>
""")
4/js
%%dojs
//...trying to use functions from testJavascript.js
也许如何做到这一点真的很简单,但我是 Colab 的新手。我收到“加载资源失败:服务器响应状态为 500 ()”。
【问题讨论】:
标签: javascript python html google-colaboratory