Skip to content

Instantly share code, notes, and snippets.

@Vidimensional
Last active August 29, 2015 14:20
Show Gist options
  • Save Vidimensional/b977e17cbe7b4d0de8ed to your computer and use it in GitHub Desktop.
Save Vidimensional/b977e17cbe7b4d0de8ed to your computer and use it in GitHub Desktop.
My first Docker thingy
FROM python:2.7-onbuild
CMD [ "python", "./netshare.py" ]
#!/usr/bin/env python
import sys
import BaseHTTPServer
from netifaces import interfaces, ifaddresses, AF_INET
ip_address = ifaddresses('eth0').setdefault(AF_INET)[0]['addr']
tcp_port = 8080
address = (ip_address, tcp_port)
try:
sharing = sys.argv[1]
except (IndexError):
print "WHAT DO YOU WANT TO SHARE?"
exit(1)
class janler (BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200, "Okei")
self.send_header("Content-Type","text/html")
self.end_headers()
self.wfile.write(sharing)
httpd = BaseHTTPServer.HTTPServer(address, janler)
print "Ok, funciono en http://%s:%s :D" % (address)
while True:
httpd.handle_request()
netifaces>=0.10.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment