A modern, secure, and privacy-focused pastebin service, built with Django.
- Modern UI: Clean, responsive design with dark/light mode support
- Syntax Highlighting: Automatic language detection and highlighting
- Password Protection: Secure paste encryption with optional passwords
- Expiration Control: Configurable paste expiration (1 day to 1 year)
- One-time Links: Self-destructing pastes after first view
- History Management: View and manage your paste history
- Raw View: View pastes without formatting
- RESTful API: Full CRUD operations for pastes
- Language Support: Get available programming languages
- Bot Authentication: Secure API access with bot tokens
- Rate Limiting: Built-in protection against abuse
- OpenAPI Documentation: Auto-generated API docs with drf-spectacular
PastedIR/
βββ π pastebinir/ # Django project settings
βββ π api/ # REST API endpoints
βββ π website/ # Web application views
βββ π templates/ # HTML templates
βββ π static/ # CSS, JS, images
βββ π compose/ # Docker configurations
βββ π nginx-configs/ # Nginx configuration templates
βββ π³ docker-compose.yml # Container orchestration
βββ π pyproject.toml # Python dependencies
- Python 3.11+
- uv
- Docker & Docker Compose
- Redis (for caching and task scheduling)
git clone https://github.com/BuddySirJava/PasteIR.git
cd PastedIR
# Copy environment file
cp example.env .env
# Edit environment variables
nano .env
# Start all services (includes PostgreSQL and Redis)
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down
# sync dependencies
uv sync
source .venv/bin/activate # Linux/Mac
# or
.venv\Scripts\activate # Windows
# Run migrations
python manage.py migrate
# Create superuser
python manage.py createsuperuser
# Start development server
python manage.py runserver
# Start scheduler worker (in another terminal)
python manage.py scheduler_worker default
The project includes pre-configured Nginx templates for production deployment:
nginx-configs/example.nginx.conf
- Main Nginx configurationnginx-configs/example.default.conf
- Server block configuration with:- Rate limiting zones
- SSL/TLS configuration
- Security headers (CSP, HSTS, etc.)
- Bot server IP whitelisting
- Static file serving optimization
- Copy the example configurations to your Nginx directory:
sudo cp nginx-configs/example.nginx.conf /etc/nginx/nginx.conf
sudo cp nginx-configs/example.default.conf /etc/nginx/sites-available/pasted.ir
-
Update the configuration files:
- Replace
example.com
with your domain - Update SSL certificate paths
- Configure your bot server IP in the whitelist
- Adjust rate limiting settings as needed
- Replace
-
Enable the site:
sudo ln -s /etc/nginx/sites-available/pasted.ir /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
- Rate Limiting: Separate zones for API, create endpoints, and general traffic
- Bot Whitelisting: IP-based and token-based bot authentication
- Security Headers: Comprehensive CSP, HSTS, and other security headers
- Static File Optimization: Efficient serving of CSS, JS, and media files
- SSL/TLS: Production-ready HTTPS configuration
# Django Settings
SECRET_KEY=your-secret-key-here
DEBUG=False
ALLOWED_HOSTS=your-domain.com,localhost
# Database (PostgreSQL)
POSTGRES_NAME=postgres
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_HOST=localhost
# Static Files
STATIC_URL=/static/
STATIC_ROOT=/static
# Security
CSRF_TRUSTED_ORIGINS=https://your-domain.com
BOT_TOKEN=your-bot-token-for-api-calls
# Redis (for caching and task scheduling)
REDIS_HOST=localhost
REDIS_PORT=6379
GET /api/pastes/
- List pastesPOST /api/pastes/
- Create new pasteGET /api/pastes/{id}/
- Get specific pasteDELETE /api/pastes/{id}/
- Delete paste
GET /api/languages/
- Get available languages
Include bot token in headers:
X-Bot-Token: your-bot-token
# Create a paste
curl -X POST https://pasted.ir/api/pastes/ \
-H "Content-Type: application/json" \
-H "X-Bot-Token: your-bot-token" \
-d '{
"content": "print(\"Hello, World!\")",
"language": 1,
"expiration": 7,
"one_time": false
}'
The application supports dark/light mode with automatic theme switching. Customize colors in templates/base.html
:
:root {
--bg-primary: #ffffff;
--text-primary: #1f2937;
/* ... more variables */
}
.dark {
--bg-primary: #1e293b;
--text-primary: #f8fafc;
/* ... more variables */
}
- Password Protection: Optional encryption for sensitive pastes
- Rate Limiting: API and bot rate limiting to prevent abuse
- CSRF Protection: Built-in Django CSRF protection
- Input Validation: Comprehensive input sanitization
- Bot Authentication: Secure API access with tokens
- Expiration Control: Automatic paste cleanup
# View application logs
docker-compose logs -f web
# View scheduler logs
docker-compose logs -f scheduler
- API health:
GET /api/health/
- Bot status:
/status
command in private chat
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
- Django - Web framework
- Django REST Framework - API framework
- highlight.js - Syntax highlighting
- Tailwind CSS - CSS framework
- Website: pasted.ir
- Issues: GitCODE_OF_CONDUCTHub Issues
- Telegram: Send Private Message
Made with β€οΈ for the Persian development community