"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to Safely Open Local HTML Files in Chrome?

How to Safely Open Local HTML Files in Chrome?

Published on 2024-12-23
Browse:998

How to Safely Open Local HTML Files in Chrome?

How to Launch HTML Using Chrome in "--allow-file-access-from-files" Mode?

Navigating this issue necessitates launching the HTML file through Google Chrome in "--allow-file-access-from-files" mode. However, it has proven unsuccessful despite repeated attempts to implement the following steps:

  1. Launch the command prompt in Windows 7.
  2. Navigate to the chrome.exe folder.
  3. Input the command: chrome --allow-file-access-from-files file:///C:/test - 3.html

Addressing the Situation

The command proposed in the steps poses a significant security risk by granting unrestricted access to the local file system. A far more secure solution lies in setting up a local HTTP server.

For Windows Users

Install the http-server package globally using Node's package manager:

npm install -g http-server

To initiate the HTTP server within a specific project directory, simply execute:

Eg. d:\my_project> http-server

A message will appear, indicating the successfully running server.

Alternatively, Python can be installed on Windows to execute the following commands.

For Linux Users

As Python is generally included in Linux distributions, executing the following command in the project directory will suffice:

python -m SimpleHTTPServer

Your browser can then access the page via http://localhost:8000.

For Python 3, the command is modified to:

python3 -m http.server.

Adopting this approach eliminates potential security vulnerabilities while providing a simple solution to the underlying issue.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3