A simple, fast FastAPI web application for uploading and managing photos locally with a modern web interface.
- FastAPI Application - Modern, responsive web interface
- Drag & Drop Upload - Intuitive file upload with drag-and-drop support
- Real-time Progress - Visual upload progress and feedback
- Photo Gallery - Browse and manage uploaded photos
- Responsive Design - Works perfectly on desktop and mobile devices
- Local Storage - All photos stored securely on your local filesystem
- File Validation - Supports multiple image formats (JPEG, PNG, GIF, WebP, BMP, TIFF)
- Metadata Storage - JSON metadata files store upload information and tags
- File Size Limits - Configurable maximum file size (default: 100MB)
- Album Organization - Tag photos with album names and descriptions
src/
βββ uploads/
β βββ photos/
β βββ 2024-01-15_vacation_photo_abc123.jpg
β βββ 2024-01-15_vacation_photo_abc123.jpg.metadata.json
β βββ ...
βββ static/
βββ templates/
βββ main.py
βββββββββββββββββββ ββββββββββββββββββββββββ βββββββββββββββββββββββ
β FastAPI App β β Local File System β β JSON Metadata β
β βββββΆβ βββββΆβ Files β
β β’ Web Interface β β β’ Image Storage β β β’ Upload Info β
β β’ File Upload β β β’ Directory Based β β β’ Tags & Albums β
β β’ Photo Gallery β β β’ Filename Based β β β’ File Details β
β β’ REST API β β β β β
βββββββββββββββββββ ββββββββββββββββββββββββ βββββββββββββββββββββββ
- Python 3.8+ installed
- Git (for cloning the repository)
# Clone the repository
git clone <repository-url>
cd photo_uploader
# Create virtual environment
python -m venv .venv
# Activate virtual environment
source .venv/bin/activate # On macOS/Linux
# or
.venv\Scripts\activate # On Windows
# Install dependencies
cd src
pip install -r requirements.txtThere are two ways to start the application:
Option A: Using the startup script (recommended)
# Make the script executable (first time only)
chmod +x run.sh
# Start the application
./run.shOption B: Manual startup
# Navigate to src directory
cd src
# Run the FastAPI application
uvicorn main:app --reload --host 127.0.0.1 --port 8080Open your browser and navigate to:
- Main Application: http://localhost:8000
- Photo Gallery: http://localhost:8000/gallery
- API Documentation: http://localhost:8000/api/docs
- Health Check: http://localhost:8000/health
- Go to http://localhost:8000
- Drag and drop image files or click to select
- Optionally add album name and description
- Click "Upload Photo"
- Navigate to http://localhost:8000/gallery
- Browse your uploaded photos
- Photos are displayed with metadata
- Click on photos to view details or delete them
Use the REST API endpoints:
GET /api/photos- List all photosGET /api/photos/{filename}/image- Get photo imageGET /api/photos/{filename}/details- Get photo detailsDELETE /api/photos/{filename}- Delete a photo
photo_uploader/
βββ src/
β βββ main.py # Main FastAPI application
β βββ requirements.txt # Python dependencies
β βββ uploads/
β β βββ photos/ # Local photo storage
β β βββ metadata/ # JSON metadata files
β βββ static/
β β βββ style.css
β β βββ script.js
β βββ templates/
β βββ index.html # Upload page
β βββ gallery.html # Photo gallery
β βββ upload_success.html
β βββ error.html
βββ run.sh # Startup script
βββ README.md
βββ SETUP_COMPLETE.md
The application can be configured by modifying the Config class in main.py:
class Config:
def __init__(self):
self.upload_dir = Path("uploads/photos") # Change upload directory
self.metadata_dir = Path("uploads/metadata") # Metadata storage
self.max_file_size = 100 * 1024 * 1024 # 100MB max file size
self.allowed_extensions = {'.jpg', '.jpeg', '.png', '.gif', '.webp', '.bmp', '.tiff'}- Supported Formats: JPEG, PNG, GIF, WebP, BMP, TIFF
- File Size Limit: 100MB (configurable)
- Metadata Storage: JSON files alongside images
- Unique Filenames: Automatic timestamp-based naming to prevent conflicts
- Modern UI: Tailwind CSS styling
- Responsive Design: Works on desktop and mobile
- Drag & Drop: Easy file upload
- Real-time Feedback: Upload progress and status
- Photo Gallery: Grid view with details modal
-
Import Errors: Make sure you've activated the virtual environment and installed dependencies
source .venv/bin/activate # Activate virtual environment pip install -r src/requirements.txt # Install dependencies
-
Permission Errors: Ensure the application has write permissions to the uploads directory
chmod 755 src/uploads/ # Set directory permissions -
Port in Use: Change the port if 8000 is already in use
uvicorn main:app --reload --host 0.0.0.0 --port 8080 # Use port 8080 instead -
Upload Directory Not Found: The application will create directories automatically, but ensure the src directory exists
To run in development mode with auto-reload:
cd src
uvicorn main:app --reload --host 0.0.0.0 --port 8000Once running, visit http://localhost:8000/api/docs for interactive API documentation with Swagger UI.
This application is designed to run locally, but you can also deploy it to various platforms:
# Install production dependencies
pip install gunicorn
# Run with gunicorn
cd src
gunicorn main:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000If you want to containerize the application:
# Build the Docker image
docker build -t local-photo-uploader .
# Run the container
docker run -p 8000:8000 -v ./uploads:/app/uploads local-photo-uploader- File System Permissions: Ensure proper permissions on upload directories
- Input Validation: The app validates file types and sizes
- Local Access: By default, the app binds to all interfaces (0.0.0.0) - use 127.0.0.1 for localhost-only access
- File Storage: Photos are stored locally with unique filenames to prevent conflicts
- HTTPS: Consider using a reverse proxy (nginx) with SSL for production
- Firewall: Configure firewall rules if exposing to network
- Access Control: Add authentication if needed for multi-user scenarios
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please read our contributing guidelines and submit pull requests for any improvements.
β‘ Simple, fast, and reliable local photo management