Skip to content

Instantly share code, notes, and snippets.

@bluerogue
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bluerogue/65ac625d7a639777badf to your computer and use it in GitHub Desktop.
Save bluerogue/65ac625d7a639777badf to your computer and use it in GitHub Desktop.
Single Line HTTP Server and Webpage
# This is a single line command to executed directly in the CLI. This will NOT run as a shell script
# as-is. This assumes you have Python installed and should work on any Mac OS X system and most
# linux systems.
#
# This changes to the user's home directory, creates and changes into a public_html directory,
# creates a file called index.html with the contents "Hello, {username}", starts a Python HTTP server,
# and finally attempts to open your default browser to the webpage. If this last step doesn't happen,
# simply open a browser and go to http://127.0.0.1:8080.
cd && mkdir public_html && cd public_html && echo 'Hello,' $USER >> index.html && python -m SimpleHTTPServer 8080 & open http://127.0.0.1:8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment