Last active
December 20, 2015 23:29
-
-
Save sansumbrella/6213010 to your computer and use it in GitHub Desktop.
Script to start a local server in the current directory. Basically a fancy SimpleHTTPServer, in that it's accessible by other devices on your LAN and it prints out the server address on startup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
# Server config: http://stackoverflow.com/questions/4139170/bind-httserver-to-local-ipport-so-that-others-in-lan-can-see-it | |
# IP address: http://stackoverflow.com/questions/166506/finding-local-ip-addresses-using-pythons-stdlib | |
import socket | |
import BaseHTTPServer | |
from SimpleHTTPServer import SimpleHTTPRequestHandler | |
# Announce the IP address and port we will serve on | |
port = 8000 | |
print("Serving on %s:%s") % (socket.gethostbyname(socket.getfqdn()), port) | |
# Start a server to accept traffic | |
addr = ("0.0.0.0", port) | |
server = BaseHTTPServer.HTTPServer(addr, SimpleHTTPRequestHandler) | |
server.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment