Created
December 27, 2019 06:46
-
-
Save jayvi/d909c82362612587630ffb92d0aff34c to your computer and use it in GitHub Desktop.
Easy way to setup a local HTTP Server on macOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You want to run a simple local HTTP Server on your local PC. You want to test your html, js,… files locally. | |
Here is the easiest way to do it. | |
1. Using SimpleHTTPServer | |
Create your test folder, move all your html, js files to that folder. | |
$ mkdir test | |
$ cd test | |
Check your python version | |
$ python --version | |
If you have Python version 2, run SimpleHTTPServer using | |
$ python -m SimpleHTTPServer 1313 | |
If you have Python version 3, using | |
$ python -m http.server 1313 | |
You will have your local HTTP Server running in port 1313. Using your Web Browser and access to http://localhost:1313/ | |
2. Using http-server | |
If you are more familiar with Node.js, http-server is your choice. If you are new to Node.js, why not give it a try. | |
Take 1 minute to go to Node.js homepage to download and install it. | |
Install http-server using: | |
$ npm install http-server -g | |
Go under the folder you want to serve your files and setup your local server by running this command: | |
$ http-server ./ -p 1313 | |
Now you have your local HTTP Server running in port 1313. Using your Web Browser and access to http://localhost:1313/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment