Skip to content

Instantly share code, notes, and snippets.

@Jeasonfire
Created September 25, 2015 21:47
Show Gist options
  • Save Jeasonfire/ac39c039247db9a05b4a to your computer and use it in GitHub Desktop.
Save Jeasonfire/ac39c039247db9a05b4a to your computer and use it in GitHub Desktop.
A quick way to host a server using Python.
Here are the instructions on how to quickly host a local server.
Maybe you need a server for some webdev thing and you haven't set up one yet?
1. Get Python 2.x or 3.x. (https://www.python.org/)
2. Navigate to a desired directory in your terminal. This will be the directory that will be accessed when connecting to this server.
3. If you have Python 2.x, continue, if you have 3.x, skip to step 4.
- Run the command "python -m SimpleHTTPServer port". (Replace the "port" with the port you want to use, eg. 8080)
4. If you have Python 3.x, continue, if you have 2.x, you're done already!
- Run the command "python -m http.server port". (Replace the "port" with the port you want to use, eg. 8080)
Now you can connect to "localhost:port" in your browser, and you'll see whatever you have put in the directory you ran the command in!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment