Using the Autograder with ngrok

The assignments for this course are expected to be run on PythonAnywhere and as such they have a globally accessible URL like https://drchuck.pythonanywhere.com and can be directly submitted to the autograder for testing.

For whatever reason, you might prefer to install and run Django locally on your computer. This is a fine solution for the course, but to submit the applications on your local computer to the autograder, you need to use a tool like ngrok or localtunnel.

This document serves as a quick guide for using ngrok to submit your applications to the autograder.

Installing ngrok for Autograding

Installing ngrok is very simple, you can download a ZIP file from https://ngrok.com/ and unzip that file anywhere on your computer. You might want to read the documentation on the web site to familiarize yourself with ngrok. They have nice diagrams that explain how ngrok works and why ngrok is needed to allow access to your local web server.

Running ngrok on Apple

Download the ngrok.zip file to your Downloads folder and then extract it by double clicking on the downloaded file and it will unzip and produce a single file called ngrok. You can put this file anywhere on your computer but for now we will just execute it from the Downloads folder. Make sure your Django application is up and running and then open up a Terminal Window as follows:

$ cd Downloads/
$ ls
ngrok               ngrok_2.0.19_darwin_amd64.zip
$ ./ngrok http 8000

Tunnel Status       online                                            
Version             2.0.19/2.0.19                                     
Web Interface       http://127.0.0.1:4040                             
Forwarding          http://c5343c6e.ngrok.io -> localhost:8000        
Forwarding          https://c5343c6e.ngrok.io -> localhost:8000       
                                                                                
Connections         ttl     opn     rt1     rt5     p50     p90       
                    0       0       0.00    0.00    0.00    0.00 
Replace "8000" with whatever port your web server is running on. Then nagivate in your browser to the address that ngrok has chosen for you. Do not include the port number on the ngrok url.
http://c5343c6e.ngrok.io
At that point you should see the same thing as you would see if you went to
http://localhost:8000/
And you can go to paths other than the root like:
http://c5343c6e.ngrok.io/catalog
Your local web server will be visible to the Internet at the ngrok-chosen address until you end the ngrok application. To terminate the ngrok on the Apple, simply press "CTRL-C" to aport the program. At that point, your local web server can no longer be accessed through ngrok.

Each time you run ngrok you will get a new address unless you sign up and pay for an address that does not change each time you run it.

Running ngrok on Windows

Download the ngrok.zip file to your Downloads folder and then extract it by clicking on the downloaded file and selecting "Extract All". It will make a folder like "ngrok_2.0.19_windows_386" and in that folder, you will find a single file named ngrok.exe. You You can put this file anywhere on your computer but for now we will just execute it from the Downloads folder. Make sure your Django application is up and running and then open up a Command Line window as follows:

C:\...> cd Downloads\ngrok_2.0.19_windows_386
C:\...> ngrok http 8000

Tunnel Status       online                                            
Version             2.0.19/2.0.19                                     
Web Interface       http://127.0.0.1:4040                             
Forwarding          http://c5343c6e.ngrok.io -> localhost:8000        
Forwarding          https://c5343c6e.ngrok.io -> localhost:8000       
Replace "8000" with whatever port your web server is running on. Then nagivate in your browser to the address that ngrok has chosen for you. Do not include the port number on the ngrok address.
http://c5343c6e.ngrok.io
At that point you should see the same thing as you would see if you went to
http://localhost:8000/
And you can go to paths other than the root like:
http://c5343c6e.ngrok.io/catalog
Your local web server will be visible to the Internet at the ngrok-chosen address until you end the ngrok application. To terminate the ngrok on the Apple, simply press "CTRL-Z" to aport the program. At that point, your local web server can no longer be accessed through ngrok.

Each time you run ngrok you will get a new address unless you sign up and pay for an address that does not change each time you run it.