Skip to content

Instantly share code, notes, and snippets.

@carlsmith
Last active January 19, 2017 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlsmith/cbf29a3b9764bebc0c7adcb93905c3d4 to your computer and use it in GitHub Desktop.
Save carlsmith/cbf29a3b9764bebc0c7adcb93905c3d4 to your computer and use it in GitHub Desktop.
IPython line magic for launching a static fileserver. It uses Ruby as the Python fileserver sucks a bit.
import os
from IPython.core.magic import register_line_magic as line_magic
@line_magic
def fileserver(args):
path, port = args.split(" ") if args else (".", "8080")
os.system('ruby -run -ehttpd "{}" -p{}'.format(path, port))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment