
A small tip that comes in handy for local testing and development – run your own Python server in 1 terminal command.
If Python is installed* (and it is on Macs by default), go to the directory containing the files you want served, and enter the following in your terminal:
python -m SimpleHTTPServer
By default the files will be served on port 8000. In a browser, go to localhost:8000 to have some files served up. Mmmm, files.
That’s it! You have a server running locally.
If you’d like to change from the default port to another, add your preferred port number after the command, e.g.:
python -m SimpleHTTPServer 3000
Your files will be served on port 3000.
Congratulations!
* Check with python –version in your terminal
Learn more: