Using Ngrok on Macintosh

In this document we show you how to submit your running application to the autograder. The PHP autograder wants to "use" your application and test it by sending requests and checking the responses from your application.

You cannot submit a URL like http://localhost:8888/homework/guess.php because "localhost" only works for network conections originating within your computer and your computer protects your computer from incoming connectsion (i.e. they are blocked by a firewall).

Unless you install your application on a server with Internet connectivity and a domain name, you need to use a program like ngrok to submit your program to the autograder.

Applications like ngrok can make a temporary hole through your firewall and give you a temporary domain name you can use to submit your application to the Autograder.

Ngrok is a "freemium" product that provided a low-level of service for free. The free level of the product should be sufficient for the purposes of autograding your assignment for this course.

Video Tutorial

You can watch a video demonstrating the use of Ngrok on Macintosh at:

https://www.youtube.com/watch?v=2QdAqK7_dU0

Installing Ngrok

First you need to download and install ngrok from www.ngrok.com. When you download the file it will probably end up in Downloads folder. You can double-click the ZIP file to unzip it to create a file named ngrok;

To run ngrok from the Downloads folder, in the terminal window type:

cd ~/Downloads
./ngrok http 8888

Ngrok should start up and show a user interface like this:

You should note the temporary URL that ngrok has assigned you for use later. In this example, the temporary URL is http://f01f774d.ngrok.io - record that for later.

You can place the ngrok executable command in any folder you like. If you like, you can place it in a folder that is in your path and then type ngrok from any folder on your system.

Checking Your Application Locally

First make sure that you know that your application is running on localhost:

Checking Your Application Via NGrok

Construct the ngrok url by removing the "http://localhost:8888" and replace it with the ngrok-provided URL:

Local: http://localhost:8888/wa4e/solutions/guess/guess.php
Ngrok: http://f01f774d.ngrok.io/wa4e/solutions/guess/guess.php

Test that url in your browser. The ngrok and local urls should return the exact same page.

Once you have verifed your application is working, submit the ngrok url to the autograder.

Interestingly, ngrok shows you as it is forwarding the various HTTP requests back and forth.

Closing Ngrok

You can press CTRL-C in the ngrok terminal window or simply close the ngrok window.

Remember that each time you start ngrok, it will assign you a different random address.