0

I wrote a HTML page with some Javascript for offline data visualization with D3js.

Now, I simply want to open my page at work calling it from a code (like python or MATLAB for example).

So, I've found the command --allow-file-access-from-files for loading the D3js library and my script. This is the page where I found the option.

I need a solution feasible for me and my collegues: I placed my HTML page on a shared path so everyone could launch the page but, as it is pointed out here, the --allow-file-access-from-files option is quite dangerous for security.

So here my questions:

  • Is there a option I can use to open a new Chrome instance in offline mode by command line?

  • Do I need a local server (e.g. via Python http.server) to combine my goal with the needed security?

I would prefer avoiding forcing my colleagues to install further programs (like Python).

Any suggestion is really appreciated.

Marco
  • 367
  • 1
  • 10

1 Answers1

1

If you are on same network which I assume you are you can install simple http server i.e http-server and run it in the directory which you have files in. And your colleagues will be able to access files over the network which is far better solution than shared file in my opinion.

Assumptions you have node installed, and you and your colleagues are on the same network.

Additionally you could actually server file over the internet if they are not on the same network but that is far less secure option.

Full example:

Install http server globally or locally npm i -g http-server

Run the server in the directroy where you have your assets (HTML,JS, ..etc) http-server .

Then your colleagues can easily connect to your machine If they are on the same network. If for some reason http-server fails to tell you your local address in the form of something along this lines http://192.168.X.X:8080 then proceed to find your local address manually.

ukaric
  • 428
  • 1
  • 7
  • 22
  • Thank you for the answer. If I'm not mistaken, I should run an ongoing server and leave it open. Is it correct? – Marco Mar 11 '18 at 17:40
  • Yeah as long as the server is running they will be able to connect to it you could run it basically forever or in background simply by typing http-server . & > /dev/null. This will allow http-server to run in the background and > pipes the output to null so you don't get annyoing feedback in the terminal when someone access the file. To see running `jobs` type jobs and then you will have PID and to kill the server that is running in background just type kill %PID of the process in most cases 1. – ukaric Mar 11 '18 at 17:43
  • Is there a way by which everyone will be independent by my PC? Apart from launching their own local server. For that reason I would thinking about a Chrome offline mode. – Marco Mar 11 '18 at 17:52
  • Yeah there are services like `now.sh` that will allow you to host stuff online for free and get link that you can freely share but that is public and anyone can access it. As far as full independence Chrome offline mode is not bad idea but certainly is a bad security practice. – ukaric Mar 11 '18 at 20:10