Simple Local Servers

December 09, 2017

When testing many facets of the OptinMonster embed code I find myself needing a clean & quick HTML page on almost a daily basis. For most tasks throwing some code into JSFiddle will do, but testing some of our more advanced targeting rules becomes onerous, if not impossible.

In comes a great little NPM package serve from the team over at Zeit that gives you a bare-bones web server from the terminal.

So without further ado, my process:

Install the package

> npm i -g serve

Create the necessary files

I first create a new temporary directory and add an index.html file.

> mkdir om-test && cd om-test
> touch index.html

Add the HTML

I then place some boilerplate HTML in index.html along with the OptinMonster embed code.

<head><title>OptinMonster Test</title></head>
    <h1>I'm OptinMonster Testing Rick!</h1>
    <!-- OptinMonster embed code goes here -->

Start the server

Back in the terminal and in the temporary directory, start the server with server ..

Screenshot of the local server running in the terminal

Once you see “Serving!” your page is ready to go!

View the page

You can now see the test page at http://localhost:5000.

That’s it.

Profile picture

Written by Aaron Eaton