Skip to content
Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ–ΌοΈ Local Photo Uploader - FastAPI Web Application

A simple, fast FastAPI web application for uploading and managing photos locally with a modern web interface.

✨ Features

🌟 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

πŸ›‘οΈ File Management Features

  • 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

πŸ“ Storage Structure

src/
β”œβ”€β”€ uploads/
β”‚   └── photos/
β”‚       β”œβ”€β”€ 2024-01-15_vacation_photo_abc123.jpg
β”‚       β”œβ”€β”€ 2024-01-15_vacation_photo_abc123.jpg.metadata.json
β”‚       └── ...
β”œβ”€β”€ static/
β”œβ”€β”€ templates/
└── main.py

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   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      β”‚    β”‚                      β”‚    β”‚                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Prerequisites

  • Python 3.8+ installed
  • Git (for cloning the repository)

1. Clone and Setup

# 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.txt

2. Run the Application

There 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.sh

Option B: Manual startup

# Navigate to src directory
cd src

# Run the FastAPI application
uvicorn main:app --reload --host 127.0.0.1 --port 8080

3. Access the Application

Open your browser and navigate to:

πŸ“Έ Usage

Upload Photos

  1. Go to http://localhost:8000
  2. Drag and drop image files or click to select
  3. Optionally add album name and description
  4. Click "Upload Photo"

View Gallery

  1. Navigate to http://localhost:8000/gallery
  2. Browse your uploaded photos
  3. Photos are displayed with metadata
  4. Click on photos to view details or delete them

API Usage

Use the REST API endpoints:

  • GET /api/photos - List all photos
  • GET /api/photos/{filename}/image - Get photo image
  • GET /api/photos/{filename}/details - Get photo details
  • DELETE /api/photos/{filename} - Delete a photo

πŸ“ Project Structure

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

βš™οΈ Configuration

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'}

πŸ”§ Features

File Support

  • 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

Web Interface

  • 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

πŸ› Troubleshooting

Common Issues

  1. 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
  2. Permission Errors: Ensure the application has write permissions to the uploads directory

    chmod 755 src/uploads/  # Set directory permissions
  3. 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
  4. Upload Directory Not Found: The application will create directories automatically, but ensure the src directory exists

Development

To run in development mode with auto-reload:

cd src
uvicorn main:app --reload --host 0.0.0.0 --port 8000

πŸ“ API Documentation

Once running, visit http://localhost:8000/api/docs for interactive API documentation with Swagger UI.

πŸš€ Deployment

This application is designed to run locally, but you can also deploy it to various platforms:

Local Production

# 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:8000

Docker (Optional)

If 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

πŸ”’ Security Considerations

Local Deployment

  1. File System Permissions: Ensure proper permissions on upload directories
  2. Input Validation: The app validates file types and sizes
  3. Local Access: By default, the app binds to all interfaces (0.0.0.0) - use 127.0.0.1 for localhost-only access
  4. File Storage: Photos are stored locally with unique filenames to prevent conflicts

Network Security

  • 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

πŸ“– Additional Resources

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

🀝 Contributing

Contributions are welcome! Please read our contributing guidelines and submit pull requests for any improvements.


⚑ Simple, fast, and reliable local photo management

About

Sample Python web application used for UX Studies / testing.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages