Skip to content

Instantly share code, notes, and snippets.

@yourcelf
Created March 7, 2013 00:36
Show Gist options
  • Save yourcelf/5104523 to your computer and use it in GitHub Desktop.
Save yourcelf/5104523 to your computer and use it in GitHub Desktop.
Run python's simple http server in the current directory with the specified port.
#!/usr/bin/env python
import sys
import subprocess
ports = sys.argv[1:] or [8000]
procs = []
for port in ports:
procs.append(
subprocess.Popen(["python", "-m", "SimpleHTTPServer", str(port)])
)
try:
procs[-1].communicate()
except KeyboardInterrupt:
for proc in procs:
proc.kill()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment