Skip to content

Instantly share code, notes, and snippets.

@MikeTrizna
Created July 16, 2019 14:33
Show Gist options
  • Save MikeTrizna/0263ba97e8d040dbd2271a3b258ac4df to your computer and use it in GitHub Desktop.
Save MikeTrizna/0263ba97e8d040dbd2271a3b258ac4df to your computer and use it in GitHub Desktop.
Barebones iframe attempt
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"metadata": {},
"cell_type": "markdown",
"source": "First, clone the *gh-pages* branch of the sample GitHub repo I set up for the NMAH demo."
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2019-07-16T14:28:14.658790Z",
"end_time": "2019-07-16T14:31:26.276069Z"
},
"trusted": true
},
"cell_type": "code",
"source": "!git clone --branch gh-pages https://github.com/MikeTrizna/nmah_image_ml.git",
"execution_count": 1,
"outputs": [
{
"output_type": "stream",
"text": "Cloning into 'nmah_image_ml'...\nremote: Enumerating objects: 4550, done.\u001b[K\nremote: Total 4550 (delta 0), reused 0 (delta 0), pack-reused 4550\u001b[K\nReceiving objects: 100% (4550/4550), 101.17 MiB | 548.00 KiB/s, done.\nResolving deltas: 100% (4/4), done.\nChecking out files: 100% (4612/4612), done.\n",
"name": "stdout"
}
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": "Next, use this strange `get_ipython().system_raw()` function to launch a local server on port 8080."
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2019-07-16T14:31:44.241137Z",
"end_time": "2019-07-16T14:31:44.256574Z"
},
"trusted": true
},
"cell_type": "code",
"source": "get_ipython().system_raw('python3 -m http.server 8080 &')",
"execution_count": 2,
"outputs": []
},
{
"metadata": {},
"cell_type": "markdown",
"source": "Finally, import the IPython library function `IFrame` to \"embed\" the localhost website that was launched in the previous step."
},
{
"metadata": {
"ExecuteTime": {
"start_time": "2019-07-16T14:32:21.776291Z",
"end_time": "2019-07-16T14:32:21.788605Z"
},
"trusted": true
},
"cell_type": "code",
"source": "from IPython.display import IFrame\n\nIFrame(\"http://localhost:8080/nmah_image_ml/index.html\", 800,800)",
"execution_count": 3,
"outputs": [
{
"output_type": "execute_result",
"execution_count": 3,
"data": {
"text/plain": "<IPython.lib.display.IFrame at 0x10ab38080>",
"text/html": "\n <iframe\n width=\"800\"\n height=\"800\"\n src=\"http://localhost:8080/nmah_image_ml/index.html\"\n frameborder=\"0\"\n allowfullscreen\n ></iframe>\n "
},
"metadata": {}
}
]
},
{
"metadata": {
"trusted": true
},
"cell_type": "code",
"source": "",
"execution_count": null,
"outputs": []
}
],
"metadata": {
"kernelspec": {
"name": "python3",
"display_name": "Python 3",
"language": "python"
},
"language_info": {
"name": "python",
"version": "3.7.1",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
},
"gist": {
"id": "",
"data": {
"description": "Barebones iframe attempt",
"public": false
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment