None
A Quick Visibility Hack
Sunday, 03 January 2016 21:30 Hrs
❝ Quick hack to make a machines directory visible on a network.

5 minute hack that is useful.

There's nothing spectacular about this hack. It simply allows me to make a directory on a crappy Windows machine visible on the network by directory path. I run the script using Idle so I don't even have to be into the directory I want to expose.

####====== start ======

#!/usr/bin/env python3

#======
# name: server.py
# date: 2016JAN01
# prog: pr
# desc: I cant get the filepath to work on windows so I
#       created a quick, dirty hack to allow for files
#       to be served over the network.
# src :
# <https://docs.python.org/3.3/library/http.server.html>
# <https://docs.python.org/3.3/library/os.html#os.listdir>
#======

import os
import http.server
import socketserver

PORT = 8000                                  
DIR = "D:\\download\\seldomlogical-old\\"    # root: path I want served
PATH = os.listdir(path=DIR)

Handler = http.server.SimpleHTTPRequestHandler
httpd = socketserver.TCPServer(("", PORT), Handler)
print("serving from path", PATH)
print("serving at port", PORT)
httpd.serve_forever()

####====== end ======

As a quick exercise I wrote the basic code in a tweet. [0] The path is contrived but it gives you an example of how compact the code is.

####====== start ======

import os,http,socketserver 
os.listdir(path='a:\\')
socketserver.TCPServer((, 8080),http.server.SimpleHTTPRequestHandler).serve_forever()

####====== end ======

Reference

[0] Equivalent code in a tweet.

  • https://twitter.com/peterrenshaw/status/682873288079495168

[Last accessed: Monday 1st February, 2016]

―~♞~―

My neek verification.

bio Another Scrappy Startup ☮ ♥ ♬ ⌨

short <seldomlogical.com/qvh.html>

contact Peter Renshaw / 🐘 — 🎨

← HOME ↖ UP TOP ↑ BEST →