Question

What is the simplest way to host an HTML page over LAN?

I literally just need to have like 5 lines of HTML, so I don't want to download and setup an Apache server. I just want to know the fastest/simplest way to do this on Windows, or I can also use one of my Linux virtual machines if it's faster.

Was it helpful?

Solution 2

Since you need a web server for testing and no heavy concurrent use is expected, I'll just keep it simple.

Please note that both solutions are very simple but not very secure, use them for development purposes but don't rely on neither of them for anything barely similar to a stable (people would say "production") server.

Navigate to the directory where your HTML file is located using cmd.exe, then issue:

Using Python

python -m SimpleHTTPServer

A HTTP server will be started on port 8000. Should you need a different port, just specify it:

python -m SimpleHTTPServer 8080

SimpleHTTPServer is part of the "batteries included": you will not need to install any extra package, apart from the Python interpreter, of course.

Python comes already installed on most Linux distributions, so switching to Linux might be simpler than install Python on Windows, although that boils down to downloading and running an installer.

Using PHP 5.4 or above

php -S 0.0.0.0:8080

This will also process PHP scripts, but HTML resources will be served fine.

OTHER TIPS

Use netcat, or nc:

:top
nc -l -p 80 -q 1 < index.html
goto top

It's a simple binary without any installation. It doesn't do CGI or PHP or anything, but it can sure dish up 5 lines of HTML.

Actually, if you use the "k" (keep-alive) option you can remove the loop, and make it simpler:

nc -kl 80 < index.html

http://www.lighttpd.net/ is pretty light weight and easy to get running.

I recently used mongoose for a similar purpose. It supports Windows. From the homepage:

Mongoose executable does not depend on any external library or configuration. If it is copied to any directory and executed, it starts to serve that directory on port 8080. If some additional config is required - for example, different listening port or IP-based access control, then a mongoose.conf file with respective options (see example) can be created in the same directory where executable lives. This makes Mongoose perfect for all sorts of demos, quick tests, file sharing, and Web programming.

Download the windows exe (no need to install) from here , save it on the folder where your html file is and execute it. Check the image below to know how to start the server:

enter image description here

After selecting Start Browser on Port 8080 your browser will open automatically displaying the contents of the folder.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top