Skip to content

Instantly share code, notes, and snippets.

@luqs1
Created January 2, 2020 23:23
Show Gist options
  • Select an option

  • Save luqs1/fa955ace49c4d2de65ffbf19e03710ea to your computer and use it in GitHub Desktop.

Select an option

Save luqs1/fa955ace49c4d2de65ffbf19e03710ea to your computer and use it in GitHub Desktop.
Host files in the directory on your IP accessible to others on the network
import socket
import os
port = input('port: ')
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
ip = s.getsockname()[0]
s.close()
print(ip+':'+port)
os.system('python -m http.server --bind '+ip+' '+port)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment