Chrome has a permissions policy for local files using the file://
protocol that disallows ajax requests, and some APIs won't work on the file://
protocol. We recommend running a simple server on your machine. Here are the options:
Command Line stuff (Python)
Mac or Linux
Macs and most Linux distros come with Python preinstalled. The following steps should work without additional setup:
- Open Terminal
- Navigate to your project directory. You can do this using the
cd
command in the terminal. - Run this command:
python -m SimpleHTTPServer
- If you are running Python 3, run this command instead:
python -m http.server 8000
- If you are running Python 3, run this command instead:
- If successful, you should then be able to access your project folder by pointing your browser to http://localhost:8000
Windows
If you are running Windows, you will need to make sure you have Python installed. To check, open a command prompt and enter python
. If you see a response including the version number, Python is ready to go. Note whether the version starts with 2 or 3, press ctrl+c
to return to the regular command prompt, and follow steps 2-4 of the Mac instructions above.
If the python
command produces an error message, follow the steps below to install Python:
- Go to the Python Downloads page, and click one of the yellow buttons to download Python 2 or 3. Most of your classmates and teachers will be using Python 2, but 3 will work as well. (More info on version selection here.)
- Double-click the downloaded file to install Python.
- When the installation is complete, open PowerShell (NOT command line), and run this command:
[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27\;C:\Python27\Scripts\", "User")
(Note: This code assumes that you have installed Python 2.7. If you installed a different version, look in your C:\ drive and check the name of the "PythonXX" directory. Replace both instances of Python27 in the code above with the directory name on your computer.)
- Run the
python
command again. You should now see a response with the Python version number. Using PowerShell or command line, follow steps 2-4 of the Mac instructions above.
Without the command line (PHP)
Does all that command line stuff make you break out in a sweat? No worries! We just need a simple server up and running to be able to run code. To make it as easy as possible, you can download and install Desktop Server.
The free version is just fine. This will give you a nice GUI environment to set up a local server, and it works on both Windows and Mac. After you've installed, follow these instructions to get a server running:
- Open Desktop Server. Select "Yes. Restart Desktop Server with priviledges."
- Enter your system password if prompted
- Select "Create a new development site."
- Change the URL if you like - but "www.example.dev" is just fine.
- Select "Blank (non WordPress) as your BluePrint.
- Make a note of where the files will be located. It's likely in your Documents folder.
- Click "Create".
- Desktop Server will do its thing, and then you should see a test page when you go to your URL - www.example.dev in the browser.
- Copy your project files to the folder that was created and work on them from there.