Quick HTTP Server from Mac Terminal
Whether or not you are familiar with the built in python http server, which is a great way to serve static content from localhost, I find it cumbersome to type the actual python command.
I've made a simple function to open a new tab in the terminal and start the python server so I can get back to what I was doing in the terminal (probably vim) before deciding I need to view things in a web browser.
function serve {
osascript -e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' \
-e 'tell application "Terminal" to do script "cd '$(pwd)'; python -m SimpleHTTPServer;" in selected tab of the front window'
}
You can chuck this in your .bash_profile and then all you have to do is type serve
Written by Horia Dragomir
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Terminal
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#