Show More
@@ -981,6 +981,118 b'' | |||
|
981 | 981 | "cell_type": "markdown", |
|
982 | 982 | "metadata": {}, |
|
983 | 983 | "source": [ |
|
984 | "## Linking to files and directories for viewing in the browser\n", | |
|
985 | "\n", | |
|
986 | "It is also possible to link directly to files or directories so they can be opened in browser. This is especially convenient if you're interacting with a tool within IPython that generates HTML pages, and you'd like to easily be able to open those in a new browser window. Alternatively, if your IPython notebook server is on a remote system, creating links provides an easy way to download any files that get generated.\n", | |
|
987 | "\n", | |
|
988 | "As we saw above, there are a bunch of `.ipynb` files in our current directory." | |
|
989 | ] | |
|
990 | }, | |
|
991 | { | |
|
992 | "cell_type": "code", | |
|
993 | "collapsed": false, | |
|
994 | "input": [ | |
|
995 | "!ls" | |
|
996 | ], | |
|
997 | "language": "python", | |
|
998 | "metadata": {}, | |
|
999 | "outputs": [ | |
|
1000 | { | |
|
1001 | "output_type": "stream", | |
|
1002 | "stream": "stdout", | |
|
1003 | "text": [ | |
|
1004 | "00_notebook_tour.ipynb formatting.ipynb\r\n", | |
|
1005 | "01_notebook_introduction.ipynb octavemagic_extension.ipynb\r\n", | |
|
1006 | "Animations_and_Progress.ipynb publish_data.ipynb\r\n", | |
|
1007 | "Capturing Output.ipynb python-logo.svg\r\n", | |
|
1008 | "Script Magics.ipynb rmagic_extension.ipynb\r\n", | |
|
1009 | "animation.m4v sympy.ipynb\r\n", | |
|
1010 | "cython_extension.ipynb sympy_quantum_computing.ipynb\r\n", | |
|
1011 | "display_protocol.ipynb trapezoid_rule.ipynb\r\n" | |
|
1012 | ] | |
|
1013 | } | |
|
1014 | ], | |
|
1015 | "prompt_number": 6 | |
|
1016 | }, | |
|
1017 | { | |
|
1018 | "cell_type": "markdown", | |
|
1019 | "metadata": {}, | |
|
1020 | "source": [ | |
|
1021 | "If we want to create a link to one of them, we can call use the `FileLink` object." | |
|
1022 | ] | |
|
1023 | }, | |
|
1024 | { | |
|
1025 | "cell_type": "code", | |
|
1026 | "collapsed": false, | |
|
1027 | "input": [ | |
|
1028 | "from IPython.display import FileLink\n", | |
|
1029 | "FileLink('00_notebook_tour.ipynb')" | |
|
1030 | ], | |
|
1031 | "language": "python", | |
|
1032 | "metadata": {}, | |
|
1033 | "outputs": [ | |
|
1034 | { | |
|
1035 | "html": [ | |
|
1036 | "<a href='files/00_notebook_tour.ipynb' target='_blank'>00_notebook_tour.ipynb</a><br>" | |
|
1037 | ], | |
|
1038 | "output_type": "pyout", | |
|
1039 | "prompt_number": 2, | |
|
1040 | "text": [ | |
|
1041 | "<IPython.lib.display.FileLink at 0x10f7ea3d0>" | |
|
1042 | ] | |
|
1043 | } | |
|
1044 | ], | |
|
1045 | "prompt_number": 2 | |
|
1046 | }, | |
|
1047 | { | |
|
1048 | "cell_type": "markdown", | |
|
1049 | "metadata": {}, | |
|
1050 | "source": [ | |
|
1051 | "Alternatively, if we want to link to all of them, we can use the `FileLinks` object, passing `'.'` to indicate that we want links generated for the current working directory. Note that if there were other directories under the current directory, `FileLinks` would work in a recursive manner creating links to files in all sub-directories as well." | |
|
1052 | ] | |
|
1053 | }, | |
|
1054 | { | |
|
1055 | "cell_type": "code", | |
|
1056 | "collapsed": false, | |
|
1057 | "input": [ | |
|
1058 | "from IPython.display import FileLink\n", | |
|
1059 | "FileLinks('.')" | |
|
1060 | ], | |
|
1061 | "language": "python", | |
|
1062 | "metadata": {}, | |
|
1063 | "outputs": [ | |
|
1064 | { | |
|
1065 | "html": [ | |
|
1066 | "<a href='files/./00_notebook_tour.ipynb' target='_blank'>00_notebook_tour.ipynb</a><br>\n", | |
|
1067 | "<a href='files/./01_notebook_introduction.ipynb' target='_blank'>01_notebook_introduction.ipynb</a><br>\n", | |
|
1068 | "<a href='files/./animation.m4v' target='_blank'>animation.m4v</a><br>\n", | |
|
1069 | "<a href='files/./Animations_and_Progress.ipynb' target='_blank'>Animations_and_Progress.ipynb</a><br>\n", | |
|
1070 | "<a href='files/./Capturing Output.ipynb' target='_blank'>Capturing Output.ipynb</a><br>\n", | |
|
1071 | "<a href='files/./cython_extension.ipynb' target='_blank'>cython_extension.ipynb</a><br>\n", | |
|
1072 | "<a href='files/./display_protocol.ipynb' target='_blank'>display_protocol.ipynb</a><br>\n", | |
|
1073 | "<a href='files/./formatting.ipynb' target='_blank'>formatting.ipynb</a><br>\n", | |
|
1074 | "<a href='files/./octavemagic_extension.ipynb' target='_blank'>octavemagic_extension.ipynb</a><br>\n", | |
|
1075 | "<a href='files/./publish_data.ipynb' target='_blank'>publish_data.ipynb</a><br>\n", | |
|
1076 | "<a href='files/./python-logo.svg' target='_blank'>python-logo.svg</a><br>\n", | |
|
1077 | "<a href='files/./rmagic_extension.ipynb' target='_blank'>rmagic_extension.ipynb</a><br>\n", | |
|
1078 | "<a href='files/./Script Magics.ipynb' target='_blank'>Script Magics.ipynb</a><br>\n", | |
|
1079 | "<a href='files/./sympy.ipynb' target='_blank'>sympy.ipynb</a><br>\n", | |
|
1080 | "<a href='files/./sympy_quantum_computing.ipynb' target='_blank'>sympy_quantum_computing.ipynb</a><br>\n", | |
|
1081 | "<a href='files/./trapezoid_rule.ipynb' target='_blank'>trapezoid_rule.ipynb</a><br>" | |
|
1082 | ], | |
|
1083 | "output_type": "pyout", | |
|
1084 | "prompt_number": 7, | |
|
1085 | "text": [ | |
|
1086 | "<IPython.lib.display.FileLinks at 0x10f7eaad0>" | |
|
1087 | ] | |
|
1088 | } | |
|
1089 | ], | |
|
1090 | "prompt_number": 7 | |
|
1091 | }, | |
|
1092 | { | |
|
1093 | "cell_type": "markdown", | |
|
1094 | "metadata": {}, | |
|
1095 | "source": [ | |
|
984 | 1096 | "### External sites\n", |
|
985 | 1097 | "\n", |
|
986 | 1098 | "You can even embed an entire page from another site in an iframe; for example this is today's Wikipedia\n", |
General Comments 0
You need to be logged in to leave comments.
Login now