๐Ÿ“‚ Create a Temporary Private File-Sharing Website

๐Ÿ“‚ Create a Temporary Private File-Sharing Website

๐‰๐จ๐ข๐ง ๐œ๐จ๐ฆ๐ฆ๐ฎ๐ง๐ข๐ญ๐ฒ - ๐‚๐‹๐ˆ๐‚๐Š ๐‡๐„๐‘๐„

Want to share files between your phone, laptop, tablet, or another phone without uploading them to a public cloud?

You can turn your Android phone into a temporary private file-sharing server using Termux + Python.

The idea is simple:

Your Android Phone
       โ†“
   Termux + Python
       โ†“
 Local File Server
       โ†“
Same Wi-Fi Network
       โ†“
Phone / PC / Tablet
       โ†“
Download Files

Everything can stay on your local Wi-Fi network, so you don't need to upload your files to a third-party cloud service.


๐Ÿงฐ What You Need

  • Android phone
  • Termux
  • Python
  • Wi-Fi network
  • Another device for testing

Download Termux from the official project:

https://github.com/termux/termux-app


A โ†’ Z Practical Method

1๏ธโƒฃ Install Termux

Install Termux from its official source:

https://github.com/termux/termux-app

Open Termux after installation.


2๏ธโƒฃ Update Termux

Run:

pkg update

Then:

pkg upgrade

3๏ธโƒฃ Install Python

Run:

pkg install python

Check the installation:

python --version

You should see the installed Python version.


4๏ธโƒฃ Give Termux Storage Access

Run:

termux-setup-storage

Android will ask for permission.

Tap:

Allow

Now Termux can access your shared Android storage through:

~/storage/shared/

5๏ธโƒฃ Create Your Sharing Folder

Create a dedicated folder:

mkdir ~/share

Go inside:

cd ~/share

This folder will contain only the files you want to share.


6๏ธโƒฃ Add Files to the Folder

For example:

share/
โ”œโ”€โ”€ photo.jpg
โ”œโ”€โ”€ video.mp4
โ”œโ”€โ”€ document.pdf
โ””โ”€โ”€ app.zip

You can copy files from Android's shared storage into it.

Example:

cp ~/storage/shared/Download/document.pdf ~/share/

For a photo:

cp ~/storage/shared/DCIM/photo.jpg ~/share/

7๏ธโƒฃ Start the Temporary Server

Inside the share folder, run:

python -m http.server 8000

You should see something similar to:

Serving HTTP on 0.0.0.0 port 8000

Your phone is now running a simple web server.


8๏ธโƒฃ Open It on Your Phone

Open your Android browser and visit:

http://127.0.0.1:8000

You'll see a directory listing containing your shared files.

For example:

Directory listing

photo.jpg
video.mp4
document.pdf
app.zip

Tap a file to download/open it.


9๏ธโƒฃ Find Your Phone's Wi-Fi IP

To access the server from another device, find your phone's local IP.

Run:

ip addr

Look for the Wi-Fi interface and an address similar to:

192.168.1.25

Your actual address will be different.


๐Ÿ”Ÿ Connect Another Device

Make sure your second device is connected to the same Wi-Fi network.

On your laptop or another phone, open:

http://192.168.1.25:8000

Replace 192.168.1.25 with your phone's actual local IP.

You'll see the files from your Android phone.


1๏ธโƒฃ1๏ธโƒฃ Download a File

Tap the filename.

For example:

document.pdf

The browser will download/open it.

You can use the same method for:

  • Photos
  • Videos
  • PDFs
  • ZIP files
  • Documents
  • APKs
  • Music
  • Other files

1๏ธโƒฃ2๏ธโƒฃ Upload Files Too

Python's built-in HTTP server is mainly for serving/downloading files; it doesn't provide a file-upload webpage.

If you want:

๐Ÿ“ค Upload
๐Ÿ“ฅ Download
๐Ÿ—‘๏ธ Delete
๐Ÿ”„ Refresh

you can create a small Flask-based private file-sharing website instead.

Install Flask:

pip install flask

1๏ธโƒฃ3๏ธโƒฃ Create Your Own File-Sharing Page

Create a new folder:

mkdir ~/private-share
cd ~/private-share

Create:

nano app.py

Paste:

from flask import Flask, request, redirect, render_template_string, send_from_directory
from pathlib import Path
from werkzeug.utils import secure_filename

app = Flask(__name__)

SHARE_DIR = Path.home() / "share"
SHARE_DIR.mkdir(exist_ok=True)

HTML = """
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Private File Share</title>

    <style>
        body {
            font-family: Arial, sans-serif;
            background: #101828;
            color: white;
            max-width: 700px;
            margin: auto;
            padding: 25px;
        }

        .box {
            background: #1d2939;
            padding: 20px;
            border-radius: 15px;
            margin-bottom: 20px;
        }

        input, button {
            padding: 12px;
            margin-top: 10px;
        }

        button {
            cursor: pointer;
        }

        a {
            color: #66b3ff;
        }

        li {
            margin: 12px 0;
        }
    </style>
</head>

<body>

<h1>๐Ÿ“‚ Private File Share</h1>

<div class="box">
    <h2>Upload File</h2>

    <form method="POST" action="/upload" enctype="multipart/form-data">
        <input type="file" name="file" required>
        <br>
        <button type="submit">Upload</button>
    </form>
</div>

<div class="box">
    <h2>Available Files</h2>

    <ul>
    {% for file in files %}
        <li>
            <a href="/files/{{ file }}">{{ file }}</a>
        </li>
    {% endfor %}
    </ul>
</div>

</body>
</html>
"""

@app.route("/")
def index():
    files = sorted(
        f.name for f in SHARE_DIR.iterdir()
        if f.is_file()
    )

    return render_template_string(
        HTML,
        files=files
    )

@app.post("/upload")
def upload():
    file = request.files.get("file")

    if file and file.filename:
        filename = secure_filename(file.filename)

        if filename:
            file.save(SHARE_DIR / filename)

    return redirect("/")

@app.get("/files/<path:filename>")
def download(filename):
    return send_from_directory(
        SHARE_DIR,
        filename,
        as_attachment=True
    )

app.run(
    host="0.0.0.0",
    port=8000
)

Save the file.


1๏ธโƒฃ4๏ธโƒฃ Start Your Website

Run:

python app.py

You'll see:

Running on http://0.0.0.0:8000

Now open your phone browser:

http://127.0.0.1:8000

You'll get a proper interface:

๐Ÿ“‚ Private File Share

[ Choose File ]
[ Upload ]

Available Files

photo.jpg
video.mp4
document.pdf

1๏ธโƒฃ5๏ธโƒฃ Open It From Another Device

Find your Android IP:

ip addr

Suppose it is:

192.168.1.25

Open on your laptop:

http://192.168.1.25:8000

Now the laptop can:

Download files โ†’ Upload files

directly through the browser.


1๏ธโƒฃ6๏ธโƒฃ Make It Temporary

This is one of the best parts.

When you're finished sharing:

Go back to Termux and press:

CTRL + C

The server stops immediately.

Your website is no longer available through that server.

You can also remove the shared files:

rm -rf ~/share/*

โš ๏ธ Be careful with rm -rf and make sure you're operating on the intended folder.


1๏ธโƒฃ7๏ธโƒฃ Improve Privacy

For a private local-sharing setup:

Keep it on your trusted Wi-Fi

Don't expose the server to the public Internet.

Use a dedicated folder

Don't point the server at your entire Android storage.

Stop the server when finished

CTRL + C

Don't share sensitive files on an untrusted network

Anyone who can reach the server may potentially access what you've made available.


1๏ธโƒฃ8๏ธโƒฃ Add a Password

If you want a more complete version, Flask can add authentication so that the page requires a username/password before showing the files.

For example:

๐Ÿ“‚ Private File Share

Username:
[____________]

Password:
[____________]

       [ Login ]

This is useful when the local network isn't completely trusted.


1๏ธโƒฃ9๏ธโƒฃ Add File Deletion

You can extend the Flask application with a delete button:

photo.jpg
[ Download ] [ Delete ]

But deletion should be protected by authentication so another user can't remove your files.


2๏ธโƒฃ0๏ธโƒฃ Add Automatic Expiry

You can make the server automatically delete files after a chosen period:

Upload
   โ†“
30 minutes
   โ†“
File expires
   โ†“
Automatically deleted

Possible choices:

10 minutes
30 minutes
1 hour
6 hours
24 hours

That makes the project much more useful for temporary file sharing.


๐Ÿš€ Final Version

Your project can eventually look like:

        ๐Ÿ“ฑ ANDROID
            โ”‚
       โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”
       โ”‚ Termux  โ”‚
       โ”‚ Python  โ”‚
       โ”‚ Flask   โ”‚
       โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜
            โ”‚
      Private Wi-Fi
            โ”‚
     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”
     โ”‚             โ”‚
   ๐Ÿ’ป Laptop     ๐Ÿ“ฑ Phone
     โ”‚             โ”‚
     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
            โ”‚
     ๐Ÿ“‚ File Sharing

And the website:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚     ๐Ÿ“‚ Private File Share  โ”‚
โ”‚                            โ”‚
โ”‚   [ Choose File ]          โ”‚
โ”‚   [ Upload ]               โ”‚
โ”‚                            โ”‚
โ”‚   Available Files          โ”‚
โ”‚                            โ”‚
โ”‚   ๐Ÿ“„ document.pdf          โ”‚
โ”‚   ๐ŸŽต music.mp3             โ”‚
โ”‚   ๐ŸŽฌ video.mp4             โ”‚
โ”‚   ๐Ÿ–ผ๏ธ photo.jpg             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Termux:

https://github.com/termux/termux-app

Python:

https://www.python.org/

Python HTTP Server:

https://docs.python.org/3/library/http.server.html

Flask:

https://flask.palletsprojects.com/

Werkzeug:

https://werkzeug.palletsprojects.com/

๐Ÿ’ก Best Part

For a quick temporary share, you don't even need Flask:

cd ~/share
python -m http.server 8000

Then open:

http://PHONE-IP:8000

That's it โ€” your Android phone becomes a temporary private file server.

Report Page