One Click Folder Sharing on Lan. Ever need to offer folders or files across the network in a hurry – and don’t want to have to set up Windows IIS and all the tschacks that come along and new stuff like SoftwareOne Special Apps? I made a Python script that lets you share any folder in your network in just one click.
All you need to do is:
- Paste the Python script in the directory you want to share.
- Run the script.
- The folder instantly becomes available to other devices even a web browser using your IP address and a secure login.
IS IT SAFE?
Yes – the folder is secured via simple username and password login using HTTP Basic Auth. Your shared folder will show up as locked, and whoever tries to open it will be asked for a login. All this gives you a basic level of LAN security.
⚠️ Notice: Is fine to use inside your LAN (Local Area Network). For sharing it on the internet, you’ll need HTTPS plus some more defenses.
Without Username Password:
import http.server
import socketserver
import os
import socket
# Get local IP address
hostname = socket.gethostname()
ip_address = socket.gethostbyname(hostname)
# Port to run the server
PORT = 8080
# Serve the folder where the script is run
folder = os.getcwd()
os.chdir(folder)
print(f"Serving folder: {folder}")
print(f"Access this folder from other devices via: http://{ip_address}:{PORT}")
# Start server
handler = http.server.SimpleHTTPRequestHandler
httpd = socketserver.TCPServer(("", PORT), handler)
httpd.serve_forever()
With Username Password:
import http.server
import socketserver
import base64
import os
import socket
# === Configuration ===
USERNAME = "tricknology"
PASSWORD = "123"
PORT = 8080
# === Get local IP address ===
hostname = socket.gethostname()
ip_address = socket.gethostbyname(hostname)
# === Serve the current folder ===
folder = os.getcwd()
os.chdir(folder)
# === Custom HTTP handler with basic authentication ===
class AuthHandler(http.server.SimpleHTTPRequestHandler):
def do_HEAD(self):
self.send_response(200)
self.end_headers()
def do_AUTHHEAD(self):
self.send_response(401)
self.send_header('WWW-Authenticate', 'Basic realm="Secure Area"')
self.send_header('Content-type', 'text/html')
self.end_headers()
def do_GET(self):
key = f"{USERNAME}:{PASSWORD}"
encoded = base64.b64encode(key.encode()).decode()
auth = self.headers.get('Authorization')
if auth == f"Basic {encoded}":
super().do_GET()
else:
self.do_AUTHHEAD()
self.wfile.write(b'Authentication required.')
# === Start the server ===
with socketserver.TCPServer(("", PORT), AuthHandler) as httpd:
print(f"\n📂 Serving folder: {folder}")
print(f"🌐 Access from other devices: http://{ip_address}:{PORT}")
print(f"🔐 Username: {USERNAME} | Password: {PASSWORD}")
print("🚀 Server is running... Press Ctrl+C to stop.")
httpd.serve_forever()
Access it from any device on your LAN via:
http://<your-ip>:8080