Workshop Contents

Creative Commons-Licentie
Dit werk valt onder een Creative Commons Naamsvermelding-GelijkDelen 4.0 Internationaal-licentie.

Running a local server

the workshop starts here

When developing a website, a web designer needs to be able to see his webpages the same way the end user would. Sometimes simply clicking on and viewing your HTML files in the web browser is enough, but if you want to test dynamic content, you will need to set up a local web server. Doing this is quite simple and can easily be accomplished on Windows, Mac, and Linux. There are many types of web servers available, but we will be using the Python’s SimpleHTTPServer as it is very easy to set up.

Easy ways of doing this include running Python’s SimpleHTTPServer in your map directory.

❗ Install Python.

  • Go to python.org
  • Under the Download section, click the link for Python “3.xxx”.
  • When it has downloaded, run it.
  • On the first installer page, make sure you check the “Add Python 3.xxx to PATH” checkbox.
  • Click Install, then click Close when the installation has finished.

Next parts are divided in 2, for windows and MacOS/Linux.

Windows

On Windows open a Cmnd terminal. Menu > cmnd.exe

If you have never done this before it might look a bit scary.. But don’t worry. There is nothing we will do that will ruin your computer!

Check python installation

Let’s start by checking if you installed python.

Check if python is installed. In the command prompt type this command and press enter:

python -V

This just returns the python version number. That’s it! Did it not show the python version? Try:

py -V

Nothing? Let me know.

We will start with the most important navigation tools for the command prompt. Just imagine the command prompt is like your File Browser, but then without the fancy interface. It can do much more but we will start by navigation through it like a File Browser.

ℹ️ echo %cd% echo’s the Current Directory. It will answer with the location that we are currently in. Try it:

Type echo %cd% in the terminal and press enter!

Probably you are in your home directory.

ℹ️ dir will show all the files in your current DIRectory.

Type dir in the terminal and press enter! Do you see all the files and folders of your current working directory?

ℹ️ cd [directory] stands for Change Directory and will navigate you to the next directory you told it to.

If you have a folder named Documents, (check with dir) then type cd Documents\ in the terminal and press enter!

If we would type ‘cd’ again, you can see that you changed from your home directory to you Documents directory. If you want to go back up the working tree we can use cd .. to move 1 folder up.

Type cd .. and press enter. Check with cd where you are now.

Now you are ready to use all this information to navigate to YourDirectory where the index.html of the workshop is.

Use cd go to Yourdirectory.

This is where we will run our local server!

Start the local server

Start a HTTP server on port 8000 (which is the default port). Run :

C:\pathToIndexfile\python -m http.server

or

C:\pathToIndexfile\python -m SimpleHTTPServer

or

C:\pathToIndexfile\python.exe -m SimpleHTTPServer

For example:

"C:/Program Files/ArcGIS/Pro/bin/Python/envs/arcgispro-py3/python.exe" -m http.server

Now you can go to localhost:8000/index.html in your browser.

Continue with your initial workshop.

Linux / MacOS

On Linux open a Terminal. Menu > Terminal

If you have never done this before it might look a bit scary.. But don’t worry. There is nothing we will do that will ruin your computer!

Check python installation

Let’s start by checking if you installed python.

Check if python is installed. In the Terminal type this command and press enter:

python -V

This just returns the python version number. That’s it! Did it not show the python version? Try:

py -V

Nothing? Let me know.

We will start with the most important navigation tools for the Terminal. Just imagine the Terminal is like your File Browser, but then without the fancy interface. It can do much more but we will start by navigation through it like a File Browser.

ℹ️ pwd means Print Working Directory. It will answer with the location that we are currently in. Try it:

Type pwd in the terminal and press enter!

Probably you are in your home directory.

ℹ️ ls will LiSt all the files in your current directory.

ℹ️ cd [directory] stands for Change Directory and will navigate you to the next directory you told it to.

If you have a folder named Documents, (check with ls) then type cd Documents/ in the terminal and press enter!

If we would type ‘pwd’ again, you can see that you changed from your home directory to you Documents directory.

If you want to go back up the working tree we can use cd .. to move 1 folder up.

Type cd .. and press enter. Check with pwd where you are now.

Now you are ready to use all this information to navigate to YourDirectory where the index.html of the workshop is.

Use cd go to Yourdirectory.

This is where we will run our local server!

Start the local server

Start a HTTP server on port 8000 (which is the default port). Run:

python -m SimpleHTTPServer

Now you can go to localhost:8000/index.html in your browser.

Continue with your initial workshop.

You reached the end of this workshop!