4.0 KiB
Image Swipe App
A web application for sorting and organizing images using swipe gestures, similar to dating apps.
Features
- Swipe Interface: Swipe images in four directions (left, right, up, down) to categorize them
- Full-size Image View: Click on any image to view it in full resolution with metadata
- History Page: View all your past selections with rich filtering and sort options
- NSFW Filtering: Toggle to include/exclude NSFW images on both the main swiper and history pages
- NSFW Blur: Optional blur for NSFW thumbnails on the history page with a toolbar toggle
- Orientation & Action Filters: Filter results by orientation (portrait/landscape/square) and by action taken
- Image Sorting: Choose to display images in random order (default), oldest first, or newest first
- Database Storage: All selections are saved in a SQLite database
- Reset Functionality: Option to clear all selections and start fresh
File Structure
server.py: Entry point that starts the HTTP serverhandler.py: HTTP request handler implementing all API endpointsdatabase.py: SQLite helpers (initialisation, queries, sync)config.py: Centralised constants (paths, port)index.html: Main page with the swipe interfacehistory.html: Page to view and manage past selectionsjs/: Front-end JavaScript (main.js,utils.js, etc.)styles.css: CSS styling for the applicationupdate_nsfw_flags.py: Utility script to (re)calculate NSFW flags for existing images after changing keyword lists
How to Use
- Run the server:
python server.py - Open a web browser and navigate to
http://localhost:8000
Main Page Features
- Sort Order: Use the dropdown in the sidebar to select image display order (Random, Oldest to Newest, or Newest to Oldest)
- Mobile View: On smaller screens, action buttons appear directly below the swipe window for easy access
- Use the on-screen buttons or swipe gestures to categorize images:
- Left: Discard
- Right: Keep
- Up: Favorite
- Down: Review Later
- Click on an image to view it in full resolution
- Use the "View History" link to see all your selections. The toolbar lets you:
- Filter by action/orientation/NSFW status
- Toggle blur of NSFW thumbnails
- Sort by creation date, swipe date or resolution
- Use the "Reset Database" button in the history page to clear all selections
NSFW Detection & Maintenance
NSFW status is inferred from prompt keywords defined in config.py (NSFW_KEYWORDS).
After changing the keyword list or adding new images you can refresh the database flags:
python update_nsfw_flags.py
This will reset and recalculate all nsfw flags so that the new filters work correctly.
Requirements
- Python 3.x
- Standard Python libraries (http.server, sqlite3, etc.)
- Web browser with JavaScript enabled
Docker
If you have Docker installed you can build and run the application in an isolated container:
# Build image (only once)
docker build -t swiper-app .
# Run the container on port 8888
docker run --rm -p 8888:8888 swiper-app
Then open http://localhost:8888 in your browser.
The Dockerfile uses a minimal Python 3.11 image, installs the Python dependencies from requirements.txt, exposes port 8888 and starts the app with python server.py.
Docker Compose
A docker-compose.yml file is included so you can run the container with your image folders mounted automatically.
# Build image (first time or when code changes)
docker compose up --build
This will:
- Publish port 8888 on your host → container.
- Mount the portrait and landscape image folders (update paths in
docker-compose.ymlas needed) read-only into/media/Portraitand/media/Landscapeinside the container. - Set
IMAGE_DIRS=/media/Portrait:/media/Landscapeso the server finds the images.
Adjust ports, folders or environment variables by editing docker-compose.yml. Remember to rebuild (docker compose up --build) after changes.