Skip to content

akashdip2001/local-directory-access-Py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Serving files from your PC over LAN (Wi-Fi/Hotspot) using Python’s built-in HTTP server.

IMG20250817005946

This lets your phone (or any device on the same Wi-Fi / LAN) access your computer’s directory via a browser using your PC’s IP address and a chosen port.


🔹 Step 1: Find Your Computer’s Local IP

Open Command Prompt (cmd) on Windows and type:

ipconfig ✅

Look for:

Wireless LAN adapter Wi-Fi:
   IPv4 Address . . . . . . . . . . . : 192.168.x.x

That 192.168.x.x is your computer’s LAN IP.


Screenshot (671)

🔹 Step 2: Run Python HTTP Server

✅ Now go to the folder you want to share and open a terminal (cmd or PowerShell). Run this command:

For Python 3.x

python -m http.server 8000 ✅

or if you want to specify directory explicitly:

python -m http.server 8000 --directory "C:\Users\YourName\Videos"

This starts a server on port 8000.


🔹 Step 3: Access From Your Phone

  • Make sure your phone and laptop are on the same Wi-Fi network.
  • Open a browser on your phone and type:
http://<your_PC_IP>:8000 ✅

Example:

http://192.168.1.47:8000

Now you’ll see a directory listing like in your screenshot. You can click videos, images, or files — they’ll stream directly!


🔹 Step 4 (Optional): A Cleaner Web Server

If you want a nicer file browser, you can install http.server with autoindex (extra features):

pip install httpserver
httpserver

Or use Flask if you want a custom design:

from flask import Flask, send_from_directory
import os

app = Flask(__name__)
SHARE_DIR = "C:/Users/YourName/Videos"

@app.route('/')
def list_files():
    files = os.listdir(SHARE_DIR)
    return '<br>'.join([f'<a href="/file/{f}">{f}</a>' for f in files])

@app.route('/file/<path:filename>')
def get_file(filename):
    return send_from_directory(SHARE_DIR, filename)

if __name__ == '__main__':
    app.run(host="0.0.0.0", port=8000, debug=True)

Run it:

python app.py

Then open:

http://<your_PC_IP>:8000

ChatGPT Image Aug 17, 2025, 02_10_53 AM

About

local directory access using Python http / custom server

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors