07 June 2018
How to start a local web server to view HTML files
If you’re viewing files from your local computer in a web browser, their URL will appear with a "file:///" prefix instead of the usual "https://" that you might normally see.
Sometimes browsers give different privileges and treatment to files if they’re local or on a web server. If you need to test a local file out as if it were on a web server.
You can set up a local testing server by following the instructions in these Mozilla docs.
The short version of that is:
- open up the terminal or command prompt
- navigate to the directory where the files live
run a local python server by running:
python3 -m http.server 1234
Go to http://localhost:1234/ in your browser and navigate to or type into the address bar the file you’re trying to open
If you run into issues, the Mozilla reference is more comprehensive and should sort things out.