Go to file
Antigravity d5a9efd285 fix: burn-after-read creator bypass — show share panel instead of navigating
When a paste is created with burn_after_read enabled, redirect to the
paste view was consuming the burn before the recipient could open it.

Fix: after creating a burn paste, the creator never navigates to the
view page. Instead, paste_create.js swaps the editor for a centered
'Burn link ready' share panel showing the full URL (with key fragment)
pre-selected in a monospace input and a Copy button. The editor and nav
controls are hidden. A 'Create another' link returns to a fresh editor.

The first person to actually open the URL is always the intended
recipient, who triggers the burn as designed.
2026-05-16 12:49:44 +01:00
static fix: burn-after-read creator bypass — show share panel instead of navigating 2026-05-16 12:49:44 +01:00
templates fix: burn-after-read creator bypass — show share panel instead of navigating 2026-05-16 12:49:44 +01:00
.gitignore security: remove config.json from tracking, add example configs and nginx guard 2026-05-16 12:20:01 +01:00
README.md Initial commit — Bastebin 2026-03-26 14:44:36 +00:00
app.py feat: burn-after-read (self-destruct) paste option 2026-05-16 12:31:47 +01:00
config.example.json security: remove config.json from tracking, add example configs and nginx guard 2026-05-16 12:20:01 +01:00
generate_hash.py Implement user deletion tokens, admin panel, and security hardening 2026-03-31 12:05:06 +01:00
gunicorn.conf.py Fix port precedence: respect config.json over hardcoded defaults 2026-03-31 12:21:31 +01:00
nginx.conf.example security: remove config.json from tracking, add example configs and nginx guard 2026-05-16 12:20:01 +01:00
production.py Fix AttributeError in production.py's stop/status commands 2026-03-31 12:30:13 +01:00
requirements.txt Comprehensive security & reliability audit: hardened CSP, fixed vulnerabilities, improved theme management, and added line numbers toggle. 2026-03-27 15:22:53 +00:00
setup.py Initial commit — Bastebin 2026-03-26 14:44:36 +00:00
wsgi.py feat: burn-after-read (self-destruct) paste option 2026-05-16 12:31:47 +01:00

README.md

PasteBin - A Modern Pastebin Clone

A clean and modern pastebin website built with Python Flask and vanilla JavaScript, inspired by Hastepaste. Share code, text, and snippets with syntax highlighting, expiration options, and a beautiful dark/light theme.

Features

  • Clean, Modern UI - Responsive design with dark/light theme support
  • Syntax Highlighting - Support for 19+ programming languages using Prism.js
  • Expiration Options - Set pastes to expire after 1 hour, 1 day, 1 week, or 1 month
  • Easy Sharing - Direct links, raw text view, and embed codes
  • Download Support - Download pastes with appropriate file extensions
  • Mobile Friendly - Works great on all devices
  • Auto-save Drafts - Never lose your work with automatic draft saving
  • Keyboard Shortcuts - Ctrl/Cmd + Enter to submit, Ctrl/Cmd + K to focus
  • View Counter - Track how many times a paste has been viewed
  • Recent Pastes - Browse recently created public pastes
  • Error Handling - Proper 404/410 pages for missing/expired pastes

Supported Languages

  • Plain Text
  • JavaScript
  • Python
  • Java
  • C/C++
  • C#
  • HTML/CSS
  • SQL
  • JSON/XML
  • Bash/PowerShell
  • PHP
  • Ruby
  • Go
  • Rust
  • Markdown

Installation

Prerequisites

  • Python 3.7+
  • pip

Setup

  1. Clone the repository:

    git clone <repository-url>
    cd magic
    
  2. Create a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  3. Install dependencies:

    pip install -r requirements.txt
    
  4. Run the application:

    python app.py
    
  5. Open your browser: Navigate to http://localhost:5000

Configuration

Environment Variables

You can customize the application using these environment variables:

  • SECRET_KEY - Flask secret key (default: 'your-secret-key-change-this')
  • DATABASE - Database file path (default: 'pastebin.db')

Security

For production deployment:

  1. Change the SECRET_KEY in app.py or set the SECRET_KEY environment variable
  2. Use a proper WSGI server like Gunicorn instead of the Flask development server
  3. Set up proper error logging and monitoring

Usage

Creating a Paste

  1. Visit the homepage
  2. Enter an optional title
  3. Select the programming language
  4. Choose expiration time (or never expire)
  5. Paste your content
  6. Click "Create Paste"

Viewing Pastes

  • Regular View: Formatted with syntax highlighting
  • Raw View: Plain text for copying or embedding
  • Download: Save as a file with proper extension

Keyboard Shortcuts

  • Ctrl/Cmd + Enter - Submit the current paste form
  • Ctrl/Cmd + K - Focus on the content textarea

Theme

  • Click the moon/sun icon in the navigation to toggle between light and dark themes
  • Theme preference is saved in localStorage

Project Structure

magic/
├── app.py                 # Main Flask application
├── requirements.txt       # Python dependencies
├── pastebin.db           # SQLite database (created automatically)
├── templates/            # Jinja2 templates
│   ├── base.html         # Base template with navigation
│   ├── index.html        # Create paste page
│   ├── view.html         # View paste page
│   ├── recent.html       # Recent pastes page
│   ├── 404.html          # Not found page
│   └── 410.html          # Expired page
└── static/               # Static assets
    ├── css/
    │   └── style.css     # Main stylesheet
    └── js/
        └── app.js        # JavaScript functionality

API Endpoints

Public Endpoints

  • GET / - Create paste page
  • POST /create - Create a new paste
  • GET /<paste_id> - View paste
  • GET /<paste_id>/raw - View paste raw content
  • GET /recent - Recent pastes page
  • GET /api/languages - Get supported languages

Database Schema

The application uses SQLite with a single pastes table:

CREATE TABLE pastes (
    id TEXT PRIMARY KEY,           -- Unique paste ID
    title TEXT,                    -- Optional title
    content TEXT NOT NULL,         -- Paste content
    language TEXT DEFAULT 'text', -- Programming language
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    expires_at TIMESTAMP,          -- Optional expiration date
    views INTEGER DEFAULT 0,      -- View counter
    paste_type TEXT DEFAULT 'public'
);

Browser Support

  • Chrome 60+
  • Firefox 60+
  • Safari 12+
  • Edge 79+

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

This project is open source and available under the MIT License.

Deployment

  1. Install Gunicorn:

    pip install gunicorn
    
  2. Run with Gunicorn:

    gunicorn -w 4 -b 0.0.0.0:8000 app:app
    

Using Docker (Optional)

Create a Dockerfile:

FROM python:3.9-slim

WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . .
EXPOSE 5000

CMD ["python", "app.py"]

Build and run:

docker build -t pastebin .
docker run -p 5000:5000 pastebin

Security Considerations

  • Input validation and sanitization
  • XSS prevention through proper template escaping
  • CSRF protection via Flask's built-in mechanisms
  • Rate limiting (consider adding for production)
  • Content size limits (1MB default)

Troubleshooting

Database errors: Delete pastebin.db to reset the database Permission errors: Ensure the app has write access to the directory Port conflicts: Change the port in app.py or use environment variables Theme not saving: Check if localStorage is enabled in your browser

Acknowledgments

  • Inspired by Hastepaste and modern pastebin services
  • Uses Prism.js for syntax highlighting
  • Built with Flask web framework