A minimalist online clipboard for sharing text and files with temporary access codes.
- Text Sharing: Share text content with syntax highlighting for various programming languages
- File Upload: Upload and share multiple files (images, documents, code files, etc.)
- Temporary Access: Content expires automatically (configurable expiration time)
- Access Codes: Simple 4-digit numeric codes for easy sharing
- File Download: Download individual files or all files as a ZIP archive
- Image Preview: Built-in image viewing for common image formats
- Syntax Highlighting: Automatic language detection and syntax highlighting for code files
- Clean UI: Minimalist, responsive web interface
- JavaScript (
.js) - Python (
.py) - Java (
.java) - C# (
.cs) - C++ (
.cpp,.c) - HTML (
.html) - CSS (
.css) - JSON (
.json) - XML (
.xml) - Markdown (
.md) - SQL (
.sql) - Bash (
.sh) - Plain text (
.txt)
- JPEG (
.jpg,.jpeg) - PNG (
.png) - GIF (
.gif) - BMP (
.bmp) - WebP (
.webp) - SVG (
.svg)
- Clone the repository:
git clone <repository-url>
cd clip-rewrite- Run with Docker Compose:
docker-compose up -dThe application will be available at http://localhost:8000.
-
Prerequisites:
- Python 3.9+
- pip
-
Install dependencies:
pip install -r requirements.txt- Initialize database:
python init_db.py- Run the application:
python main.pyThe application will be available at http://localhost:8000.
-
Via Web Interface:
- Visit the homepage
- Paste text or upload files
- Set expiration time (default: 24 hours)
- Click "Create Clip"
- Save the 4-digit access code
-
Via API:
# Text content
curl -X POST "http://localhost:8000/api/clips" \
-F "content=Your text here" \
-F "expiration_hours=24"
# File upload
curl -X POST "http://localhost:8000/api/clips" \
-F "files=@example.txt" \
-F "expiration_hours=48"-
Via Web Interface:
- Go to
/retrieve - Enter the 4-digit access code
- View or download content
- Go to
-
Via API:
# Get clip info
curl "http://localhost:8000/api/clips/1234"
# Download file
curl "http://localhost:8000/api/clips/1234/download"
# Download all files as ZIP
curl "http://localhost:8000/api/clips/1234/download?download_all=true"Create a new clip with text content or files.
Parameters:
content(optional): Text contentlanguage(optional): Programming language for syntax highlightingexpiration_hours(optional, default: 24): Hours until expirationfiles(optional): Multiple files to upload
Response:
{
"access_code": "1234",
"content": "Your text here",
"language": "python",
"filename": null,
"filenames": null,
"created_at": "2025-05-26T10:00:00",
"expires_at": "2025-05-27T10:00:00",
"is_file": false,
"is_image": false
}Retrieve clip information.
Download clip files.
Query Parameters:
filename(optional): Download specific filedownload_all(optional): Download all files as ZIPas_text(optional): Force download as text file
HOST: Server host (default:0.0.0.0)PORT: Server port (default:8000)RELOAD: Enable auto-reload for development (default:true)
The application can be configured via environment variables in docker-compose.yml:
environment:
- HOST=0.0.0.0
- PORT=8000
- RELOAD=false- Files are stored in the
uploads/directory - Each clip gets its own subdirectory named after the access code
- Database stores metadata and file paths
- Files are automatically cleaned up when clips expire
The application uses SQLite by default with the following schema:
Clips Table:
id: Primary keyaccess_code: 4-digit unique codecontent: Text contentfilename: Single filename (legacy)filenames: Comma-separated list of filenamesfile_path: Path to file storagelanguage: Programming language for syntax highlightingcreated_at: Creation timestampexpires_at: Expiration timestampis_file: Boolean flag for file uploadsis_image: Boolean flag for image files
clip-rewrite/
├── app/
│ ├── __init__.py # FastAPI app factory
│ ├── models/
│ │ ├── clip.py # Database model
│ │ ├── database.py # Database configuration
│ │ └── schemas.py # Pydantic schemas
│ ├── routers/
│ │ ├── clips.py # API endpoints
│ │ └── pages.py # Web pages
│ ├── static/ # CSS, JS assets
│ └── templates/ # Jinja2 templates
├── uploads/ # File storage
├── main.py # Application entry point
├── init_db.py # Database initialization
├── requirements.txt # Python dependencies
└── docker-compose.yml # Docker configuration
# Enable auto-reload
export RELOAD=true
python main.py- Database Changes: Update
app/models/clip.pyand run migrations - API Endpoints: Add routes in
app/routers/clips.py - Web Pages: Add templates in
app/templates/and routes inapp/routers/pages.py - Frontend: Update templates and static assets
- FastAPI: Web framework
- SQLAlchemy: Database ORM
- Jinja2: Template engine
- Uvicorn: ASGI server
- Pydantic: Data validation
- python-multipart: File upload support
- aiofiles: Async file operations
- Pygments: Syntax highlighting
This project is open source. Please check the license file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
For issues and questions:
- Check existing issues in the repository
- Create a new issue with detailed information
- Include logs and error messages when reporting bugs