No description
- Go 47.1%
- HTML 27.8%
- CSS 19.5%
- JavaScript 5.1%
- Dockerfile 0.5%
|
|
||
|---|---|---|
| static | ||
| templates | ||
| .env.example | ||
| .gitignore | ||
| CLAUDE.md | ||
| docker-compose.yml | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| handlers_admin.go | ||
| handlers_auth.go | ||
| handlers_image.go | ||
| init.sql | ||
| LICENSE | ||
| main.go | ||
| models.go | ||
| README.md | ||
| settings.go | ||
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 endpoint —
POST /api/uploadreturns 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.