🏠 back to Observable

Use of download code ?

I wonder what is the use of the “download code” function available in the upper menu.
I supposed it provides with the ability to download the code of the html version of a public shared notebook (or not public if mine). But when I tried to open the index.html on my local machine, it delivers a blank page :worried:. Surprisng because all the files seem to be available : index.html, index.js, inspector.css, package.json, README.md and runtime.js.
So I deduced that I certainly did not understand the purpose of this function.
Could someone explain ?
Thank you

If you open your browser’s console you’ll see a message like the following:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///path/to/downloading-and-embedding-notebooks/index.js. (Reason: CORS request not http).

Here’s a page on that error, which has to do with the security model in the browser.

Note that the README in the tarball says this:

View this notebook in your browser by running a web server in this folder. For

python -m SimpleHTTPServer

So, you must launch a local web server to view the file.

Indeed I read The README file.
Sorry but I don’t understand what means “running a web server”.
If one achieves this with “python -m SimpleHTTPServer”, I tip this in the console and it failed.
Anyway I installed the “Web Server for Chrome” application. But it revealed as non efficient solution.

An easy way around this is to upload the downloaded code to GitHub and view it through a published version of your repository.

1 Like

Thank you for suggestion.
I’ll try it even if I don’t understand why my local process doesn’t work.

It would be great if index.html displayed something relevant in that very common case. (Issue similar to What's your method to compress FileAttachements? ?)

1 Like