Web Development
HTML Course
CSS Course
JavaScript Course
PHP Course
Python Course
SQL Course
SEO Course

Installing a Local Web Server

Most of the time, especially in the learning phase, you'll open examples directly in the browser — we do this by double-clicking the HTML file or using a direct link to it.

Local Files vs. Remote Files

When the web address path starts with file:///C:/, followed by the path to the file on the local hard drive, a local file is being used.

When the web address starts with http:// or https://, we're accessing files located remotely, on web servers.

Problems with Testing Local Files

Some documents won't run if you open them as local files. This can happen for several reasons:

Running a Simple Local HTTP Server

Python Server

To solve the problem of asynchronous requests, we need to test such examples by running them through a local web server. One of the easiest ways to do this is by using the Python SimpleHTTPServer module.

Steps:

  python -m http.server
    if it doesn't work, try
  python3 -m http.server

If something is already running on port 8000, you can choose another port by running the server command followed by an alternative port number, e.g. python -m http.server 7200. You can then access your content at localhost:7200.

Running Server-Side Languages Locally

The Python server is useful, but it doesn't know how to run code written in languages like Python or PHP. Solving this depends on the server-side language you're trying to run. Here are a few examples:


Congratulations! This introductory course ends here. In the next course, you'll learn about the HTML markup language. Good luck and happy learning!

Top