having a web server turned on doesn't necessarily mean you are serving pages on the world wide web. its what allows you to load your own static files (.html
, .js
etc.) in a browser via http://
.
if you're not sure whether or not you have a web server running, no problem! its easy to confirm.
what happens when you visit http://localhost/?
if you're looking at a webpage, great!
you're done.
the most popular web server software for microsoft computers is IIS. if its not already running, you can follow the instructions below to get things set up.
https://msdn.microsoft.com/en-us/library/ms181052(v=vs.80).aspx
afterward, save a .html
file in C:/inetpub/wwwroot
and try to access it via http://localhost/[myfile].html. if the page is served up, you're ready to roll.
Apache comes preinstalled on Apple computers. If its not running, you can follow the instructions below to get it turned on.
http://osxdaily.com/2012/09/02/start-apache-web-server-mac-os-x/
afterward, save a .html
file in ~/Users/[yourlogin]/Sites/
and try to access it via http://localhost/~[yourlogin]/myfile.html. if you can view the content, all is well.
🎵 interlude 🎵
you don't need a why, but here are a couple reasons:
- you don't have admin privileges on the computer
- you think Apache
.conf
files are scary, and editing text in VIM is even more frightening - you want something lightweight
Python comes preinstalled on Macs (and is installed on Windows with ArcGIS Software) so it's SimpleHTTPServer module is an excellent choice.
-
navigate into the folder where you plan on saving your
.html
files (using terminal/cmd) and execute the following command:python -m SimpleHTTPServer 1337
if you're using Python 3.x or higher, you'd use
python -m http.server 1337
-
now you should be able to access your own files via http://localhost:1337/myfile.html in Chrome, Firefox or any other web browser.
<html>
<body>
<h1>i'm web serving!</h1>
</body>
</html>
Node.js gets more popular by the day, so if you already have it installed (or don't mind taking two minutes to do it now) the npm module http-server
is a really good choice too.
- if you haven't already installed Node.js, visit the site below and lay it down
https://nodejs.org/en/download/
- next, open terminal or cmd and install the
http-server
module globally on your machine
npm install http-server -g
- run it using CLI (specifying the folder you'd like to serve files from)
http-server ./[yourfolder] -p 1337
- now you should be able to access your files (via something like http://localhost:1337/myfile.html) in a web browser.
This is awesome! I used it to make available some static demo HTML for use in Selenium-Webdriver examples.