Bash + Python: Quick WebServer in your current directory
Just put this script into your .bash_profile(Mac) / .bashrc(Linux) file.
#!/usr/bin/env python
#Python web-server
function webserver() {
open "http://localhost:${1:-8000}" && $(which python) -m SimpleHTTPServer ${1:-8000}
}
Then, when you're in a directory you want to use as server root call the webserver
command.
If you want to use a different port than 8000, just pass it as the first parameter
webserver 6734
That's all!
Written by Mateusz Gachowski
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#