No description
  • Go 47.1%
  • HTML 27.8%
  • CSS 19.5%
  • JavaScript 5.1%
  • Dockerfile 0.5%
Find a file
Kalvin Carefour Johnny d0a74419b5
Merge pull request #9 from kalvin0x8d0/claude/refactor-imghost-comprehensive-kLsjP
Comprehensive refactor: split monolith, add CSRF, settings cache, security fixes
2026-03-30 17:53:39 +08:00
static Add multi-tenant support with user accounts and access controls 2026-03-30 03:06:50 +00:00
templates Comprehensive refactor: split monolith, add CSRF, settings cache, security fixes 2026-03-30 09:48:39 +00:00
.env.example Comprehensive refactor: split monolith, add CSRF, settings cache, security fixes 2026-03-30 09:48:39 +00:00
.gitignore Add .gitignore to exclude compiled binary 2026-03-30 03:07:23 +00:00
CLAUDE.md Add CLAUDE.md with project guidelines and development roadmap 2026-03-29 23:41:46 +00:00
docker-compose.yml Update docker-compose.yml 2026-03-30 07:20:51 +08:00
Dockerfile Security patches, bug fixes, and architecture refactoring 2026-03-29 23:23:43 +00:00
go.mod Add multi-tenant support with user accounts and access controls 2026-03-30 03:06:50 +00:00
go.sum Add multi-tenant support with user accounts and access controls 2026-03-30 03:06:50 +00:00
handlers_admin.go Comprehensive refactor: split monolith, add CSRF, settings cache, security fixes 2026-03-30 09:48:39 +00:00
handlers_auth.go Comprehensive refactor: split monolith, add CSRF, settings cache, security fixes 2026-03-30 09:48:39 +00:00
handlers_image.go Comprehensive refactor: split monolith, add CSRF, settings cache, security fixes 2026-03-30 09:48:39 +00:00
init.sql Add multi-tenant support with user accounts and access controls 2026-03-30 03:06:50 +00:00
LICENSE Create LICENSE 2026-03-30 07:11:04 +08:00
main.go Comprehensive refactor: split monolith, add CSRF, settings cache, security fixes 2026-03-30 09:48:39 +00:00
models.go Comprehensive refactor: split monolith, add CSRF, settings cache, security fixes 2026-03-30 09:48:39 +00:00
README.md Complete rewrite in Go, HTML, CSS, JS and MariaDB 2026-03-30 07:08:42 +08:00
settings.go Comprehensive refactor: split monolith, add CSRF, settings cache, security fixes 2026-03-30 09:48:39 +00:00

ImgHost

Lightweight, self-hosted image hosting. Like Chevereto, but leaner.

Stack: Go (stdlib net/http) + MariaDB + vanilla HTML/CSS/JS

Features

  • Upload via drag-drop, file picker, or clipboard paste (Ctrl+V)
  • Share links — direct, viewer page, HTML, Markdown, BBCode
  • Thumbnails — auto-generated 300px thumbnails
  • Gallery — paginated grid view of all uploads
  • Delete tokens — each upload gets a unique delete link
  • OpenGraph / Twitter cards — shared links show image previews
  • API endpointPOST /api/upload returns JSON
  • View counter — tracks views per image

Quickstart

# 1. Clone and enter directory
cd imghost

# 2. Initialise Go modules
go mod tidy

# 3. Run with Docker Compose
docker compose up -d

Open http://localhost:8080 in your browser.

Configuration (env vars)

Variable Default Description
DB_HOST db MariaDB host
DB_PORT 3306 MariaDB port
DB_USER imghost Database user
DB_PASS imghost_secret Database password
DB_NAME imghost Database name
UPLOAD_DIR /data/uploads Upload storage path
BASE_URL http://localhost:8080 Public URL for links
MAX_UPLOAD_MB 20 Max upload size in MB

API

Upload

curl -X POST -F "image=@photo.jpg" http://localhost:8080/api/upload

Response:

{
  "slug": "a1b2c3d4e5f6",
  "url": "http://localhost:8080/i/a1b2c3d4e5f6",
  "raw": "http://localhost:8080/raw/a1b2c3d4e5f6",
  "delete": "http://localhost:8080/delete/a1b2c3d4e5f6/TOKEN"
}

Routes

Path Description
/ Upload page
/gallery Paginated gallery
/i/{slug} Image viewer page
/raw/{slug} Direct image (cacheable)
/thumb/{slug} 300px thumbnail
/delete/{slug}/{token} Delete with token
/api/upload JSON upload endpoint

Reverse proxy (Caddy)

img.yourdomain.com {
    reverse_proxy localhost:8080
}

Licence

CC0 — do whatever you want with it.