File Upload Server
A simple file upload server that accepts files and text shares from any device on your local network.
- π Upload multiple file types (images, documents, videos, PDFs)
- π Share text content directly
- π Access from any device on the same network
- π File type validation for security
- β Simple HTTP endpoint for easy integration
- π± iOS Shortcuts integration for quick sharing
- Documents: txt, pdf, doc, docx
- Images: png, jpg, jpeg, gif
- Videos: mp4, mov
-
Install Python 3.x Download from python.org if not already installed.
-
Install Flask:
pip install flask- Download the script and save it as
server.py
Run the server from your terminal:
python server.pyThe server will start on http://0.0.0.0:5000 and be accessible from any device on your network.
-
Find your computer's local IP address:
- Windows:
ipconfig(look for IPv4 Address) - Mac/Linux:
ifconfigorip addr(look for inet address)
- Windows:
-
Access the server at:
http://YOUR_IP_ADDRESS:5000/upload
Using cURL:
curl -F "file=@/path/to/your/file.jpg" http://YOUR_IP:5000/uploadUsing Python:
import requests
files = {'file': open('document.pdf', 'rb')}
response = requests.post('http://YOUR_IP:5000/upload', files=files)
print(response.text)Using JavaScript/Fetch:
const formData = new FormData();
formData.append('file', fileInput.files[0]);
fetch('http://YOUR_IP:5000/upload', {
method: 'POST',
body: formData
})
.then(response => response.text())
.then(data => console.log(data));curl -X POST -d "Your text content here" http://YOUR_IP:5000/uploadText will be saved as shared_text.txt in the server directory.
- Open Shortcuts app β Tap "+" to create a new shortcut
- Add action: Search for "Get Contents of URL"
- Configure:
- Method: POST
- URL:
http://YOUR_LAPTOP_IP:5000/upload(replace with your actual IP) - Request Body:
- Tap the "File" label (or circle next to it) and change type to Form
- Once set to Form, tap "Add New Field" (or + icon)
- Choose field type: File
- Set Key:
file(exactly, lowercase) - Set Value: Tap "Choose Variable" β Select Shortcut Input (this takes the shared photo/file from the share sheet)
- (Optional) Add more fields as "Text" type for additional data
- Note: No need to add Content-Type header β Shortcuts sets "multipart/form-data" automatically for Form with File fields
- (Optional) Add a "Show Notification" action at the end with text like "File sent!" to confirm success
- Name it something like "Share File to Laptop"
To use: In Photos app (for photos) or Files app (for files), select the item β Share β More β Run your shortcut. It will send the file to your laptop's server.
- Create a new shortcut
- Add action: "Get Contents of URL"
- Configure:
- Method: POST
- URL:
http://YOUR_LAPTOP_IP:5000/upload - Request Body:
- Tap "Add New Field" β Choose "Text"
- Key: (leave blank or use 'text')
- Value: Shortcut Input (or use "Get Clipboard" if sharing copied text)
- (Optional) Add confirmation notification
- Name it "Share Text to Laptop"
To use: Copy text β Open Shortcuts β Run it. Or add to share sheet for notes/apps.
Edit this line in the code:
app.config['UPLOAD_FOLDER'] = os.getcwd() # Change to your desired pathEdit the ALLOWED_EXTENSIONS set:
ALLOWED_EXTENSIONS = {'txt', 'pdf', 'png', 'jpg', 'zip', 'mp3'} # Add your typesModify the last line:
app.run(host='0.0.0.0', port=8080, debug=True) # Change port number- Change
app.secret_keyto a random string before production use - Files are saved to the current directory by default
- Set
debug=Falsein production environments - Consider adding authentication for sensitive use cases
- Only use on trusted networks
Port already in use:
# Use a different port
python app.py --port 5001Cannot access from other devices:
- Check firewall settings
- Ensure devices are on the same network
- Verify the correct IP address is being used
File not saving:
- Check write permissions in the upload directory
- Ensure sufficient disk space
iOS Shortcut not working:
- Verify your laptop's IP address is correct
- Ensure the server is running
- Check that both devices are on the same Wi-Fi network
- Make sure the Request Body is set to "Form" type, not "File" or "JSON"
- Quick file transfers between devices
- Mobile photo uploads to PC
- Simple document sharing in local networks
- Text snippet sharing between devices
- One-tap photo backup from iPhone to laptop
Fork the repo, make changes, and submit a pull request. Issues welcome at github.com/nadikaprabhath/file-sharing-server-python.
MIT License. Copyright (c) 2025 Nadika Prabhath. See script header for details.