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:

  1. open up the terminal or command prompt
  2. navigate to the directory where the files live
  3. run a local python server by running:

    python3 -m http.server 1234

  4. 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.




Did you find this helpful or fun? paypal.me/mrcoles
comments powered by Disqus

Peter Coles

Peter Coles

is a software engineer living in NYC who is building Superset 💪 and also created GoFullPage 📸
more »

github · soundcloud · @lethys · rss