A simple, self-hosted pastebin web application built with Flask.
Supports rate limiting, CSRF protection, encrypted contents and automatic cleanup of old pastes.
pastebin_demo.webm
- Create and share text pastes with unique URLs
- View raw paste content
- Rate limiting per IP address
- CSRF protection for POST requests
- Encrypted pastes
- Automatic deletion of pastes older than (user defined)
- Burn after reading
- Configurable via environment variables
- Runs locally or in Docker
-
Clone the repository:
git clone https://github.com/teklynk/python_paste.git cd python_paste -
Create a virtual environment:
python3 -m venv venv source venv/bin/activate -
Install dependencies:
pip install -r requirements.txt
-
Configure environment variables:
- Rename
sample.envto.env - Edit
.envand set yourSECRET_KEYandALLOWED_DOMAIN
- Rename
-
Run the application:
python3 python_paste.py
-
Deactivate the virtual environment (optional):
deactivate
-
Configure environment variables:
- Rename
sample.docker-compose.ymltodocker-compose.yml - Edit
docker-compose.ymland set yourSECRET_KEY,ALLOWED_DOMAINandENCRYPTION_KEYunder theenvironmentsection
- Rename
-
Build and run the container:
docker-compose up --build
- On first run, the app will generated a
ENCRYPTION_KEYand save it to the.envif it does not already exist. Fernet key must be 32 url-safe base64-encoded bytes. - If running locally, ensure
.envis present and configured.ENCRYPTION_KEYkey must be 32 url-safe base64-encoded bytes. - If using Docker, configure environment variables in
docker-compose.yml. Do not use the.envfile with docker. The.envis only needed when running the app locally withpython3 python_paste.py. - Pastes older than 90 days are deleted automatically if not defined in
PASTEBIN_EXPIRATION_DAYS. BURN_AFTER_READING_VIEWSis set to 3 views by default if not defined in.envordocker-compose.yml.- The app is designed to work behind a reverse proxy (e.g., Nginx, Cloudflare) and supports real client IP detection.