19 ms·
My `bin/server`. It prints all ip addresses binded to the machine, and tries port numbers starting from 8000 until one is available for use: #!/usr/bin/env p
by songgao 14y ago
My `bin/server`. It prints all ip addresses binded to the machine, and tries port numbers starting from 8000 until one is available for use:
#!/usr/bin/env python2.7
import commands
import subprocess
port=8000
while commands.getstatusoutput('lsof -i -P|grep ":' + str(port) + '"')[1]:
port = port + 1
print commands.getstatusoutput('ip addr | grep inet')[1], "\n"
subprocess.call(['env', 'python2.7', '-m', 'SimpleHTTPServer', str(port)])