本地主机拒绝连接

本地主机拒绝连接

本文介绍了在Google Colab Notebook中提供iframe服务:本地主机拒绝连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下方法从Google Colab笔记本中提供一些HTML:

I am trying to serve some HTML from a Google Colab notebook using the following:

from IPython.display import IFrame

IFrame(src='./output/index.html', width=700, height=600)

但是,这会抛出 localhost拒绝连接:

有人知道我如何在Colab笔记本中提供index.html(必须加载javascript)中的html吗?任何指针将不胜感激!

Does anyone know how I can serve the html in index.html (which must load javascript) inside the Colab notebook? Any pointers would be hugely appreciated!

推荐答案

您可以从路径/nbextensions/提供内容,该路径映射到/usr/local/share/jupyter/nbextensions.

You can serve content from the path /nbextensions/ which maps to /usr/local/share/jupyter/nbextensions.

因此您可以在其中放置内容.

So you can put content there.

!ln -s /usr/local/share/jupyter/nbextensions /nbextensions
%cd /nbextensions
!wget -q https://upload.wikimedia.org/wikipedia/commons/3/37/Youtube.svg

然后投放图片

%%html
<img src=/nbextensions/Youtube.svg>

我想,我无法使其与IFrame一起使用.我不知道为什么.

I can't make it works with IFrame, thought. I don't know why.

下面是一个示例可乐笔记本.

这篇关于在Google Colab Notebook中提供iframe服务:本地主机拒绝连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 06:27