Project: Portable File-Sharing Device

๐ Introduction
A Portable File-Sharing Device that turns your Raspberry Pi into a Wi-Fi hotspot and local web server, capable of serving files directly from a USB flash drive. The goal is simple: no internet needed โ just power it up, connect to the hotspot, and access your files via a browser at http://192.168.4.1
.
The device uses a USB flash drive as external storage, so all files you see and download through the browser are stored outside the Raspberry Pi, keeping things clean and easily swappable.
Whether youโre a student, teacher, developer, or just someone who loves tinkering with Raspberry Pi, this project is for you.
Iโm also open to fresh ideas that can make this project work easier, faster, or smarter. If you have suggestions or improvements, Iโd love to hear them!
Youโre free to build and improve it โ and credit goes to me, Ekene Agunechemba, as the original creator of this solution. For questions, collaborations, or shout-outs, feel free to reach me at: agunechemba@yahoo.com
Letโs build something useful!
๐ง Project Goal
Build a portable file-sharing device that:
- Creates a Wi-Fi hotspot
- Hosts a local web server
- Lists and serves files from a USB flash drive at
http://192.168.4.1
๐งฐ What Youโll Need
Item | Description |
---|---|
Raspberry Pi (3/4) | With built-in Wi-Fi |
MicroSD Card (8GB+) | For the OS |
USB Flash Drive | Holds files to be served |
Power Supply | Power your Pi |
HDMI/Monitor/Keyboard | For initial setup (or use SSH) |
Optional: Case | To protect your Pi |
๐ฆ Step 1: Prepare Your Raspberry Pi
-
Download and flash Raspberry Pi OS Lite
- Download Raspberry Pi Imager
- Choose Raspberry Pi OS Lite (64-bit)
- Flash it to your microSD card
- Enable SSH (create an empty file named
ssh
in boot partition)
-
Boot and connect
- Insert the card, boot the Pi
- Connect to Wi-Fi (temporarily) or access via HDMI/keyboard
๐ Step 2: Set Up the Wi-Fi Hotspot
1. Install Required Tools
sudo apt update
sudo apt install hostapd dnsmasq
2. Configure Static IP
Edit /etc/dhcpcd.conf
:
sudo nano /etc/dhcpcd.conf
Add at the bottom:
interface wlan0
static ip_address=192.168.4.1/24
nohook wpa_supplicant
3. Configure hostapd
sudo nano /etc/hostapd/hostapd.conf
Paste:
interface=wlan0
driver=nl80211
ssid=OfflineServer
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
Edit /etc/default/hostapd
:
sudo nano /etc/default/hostapd
Add:
DAEMON_CONF="/etc/hostapd/hostapd.conf"
4. Configure dnsmasq
Backup old config:
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
Create new one:
sudo nano /etc/dnsmasq.conf
Paste:
interface=wlan0
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
๐พ Step 3: Mount USB Flash Drive Automatically
- Plug in your flash drive
- Create mount point:
sudo mkdir /media/usb
- Find device name:
lsblk
- Add to
/etc/fstab
:
sudo nano /etc/fstab
Add (replace sda1
with your actual device):
/dev/sda1 /media/usb vfat defaults,nofail 0 0
๐ Step 4: Build the HTTP File Server
Using Python + Flask
- Install Flask:
sudo apt install python3-pip
pip3 install flask
- Create app file:
mkdir ~/fileserver
nano ~/fileserver/server.py
Paste this:
from flask import Flask, send_from_directory, render_template_string
import os
app = Flask(__name__)
USB_PATH = "/media/usb"
@app.route("/")
def list_files():
files = os.listdir(USB_PATH)
return render_template_string('''
<h1>Files on USB</h1>
<ul></ul>
''', files=files)
@app.route("/files/<path:filename>")
def serve_file(filename):
return send_from_directory(USB_PATH, filename)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=80)
๐ Step 5: Auto-Start Server on Boot
Create a systemd service:
sudo nano /etc/systemd/system/fileserver.service
Paste:
[Unit]
Description=Offline File Server
After=network.target
[Service]
ExecStart=/usr/bin/python3 /home/pi/fileserver/server.py
WorkingDirectory=/home/pi/fileserver
Restart=always
User=pi
[Install]
WantedBy=multi-user.target
Enable it:
sudo systemctl enable fileserver
๐ Step 6: Reboot and Test
- Reboot:
sudo reboot
- Connect your phone or PC to
OfflineServer
Wi-Fi - Open browser โ
http://192.168.4.1
- Youโll see the files from the flash drive, clickable and downloadable!
โ Optional Extras
- Add file type icons or previews
- Add upload form (if you want users to upload files)
- Add QR code that points to
http://192.168.4.1
Recommended PI Models
โ Best Choice: Raspberry Pi 4 Model B
Wi-Fi + dual-band (faster, more stable hotspot)
USB 3.0 ports (faster file access)
More RAM (1GBโ8GB options)
Faster CPU โ handles Flask/Node.js better
๐ Good Choice: Raspberry Pi 3 Model B+
Built-in Wi-Fi (single band, but works)
Enough power for hotspot + Flask server
More affordable and less power-hungry