BDFR Web Interface
A modern web interface for the Bulk Downloader for Reddit (BDFR) built with FastAPI, WebSockets, and vanilla JavaScript.
Features
- Modern UI: Clean, responsive design with gradient backgrounds and smooth animations
- Real-time Progress: WebSocket-based progress updates for active downloads
- Subreddit Downloads: Download posts from any subreddit with customizable limits and sorting
- User Downloads: Download posts from specific users
- Status Monitoring: Real-time system status and connection monitoring
- Form Validation: Client-side validation with visual feedback
- Error Handling: Comprehensive error handling with user-friendly notifications
Project Structure
web_interface/
├── app/
│ └── main.py # FastAPI application
├── static/
│ ├── css/
│ │ └── style.css # Modern CSS styling
│ └── js/
│ └── app.js # WebSocket client and form handling
├── templates/
│ └── index.html # Main web interface
└── requirements.txt # Python dependencies
Installation
-
Install Dependencies:
cd web_interface pip install -r requirements.txt -
Run the Application:
cd app python main.py -
Access the Interface: Open your browser and navigate to
http://localhost:8000
API Endpoints
Download Endpoints
POST /api/download/subreddit- Start subreddit downloadPOST /api/download/user- Start user downloadGET /api/downloads- List all active downloadsGET /api/downloads/{download_id}- Get specific download statusDELETE /api/downloads/{download_id}- Cancel download
WebSocket
ws://localhost:8000/ws/progress- Real-time progress updates
Status Endpoints
GET /- Main web interfaceGET /health- Health checkGET /api/bdfr/status- BDFR system status
Configuration
The application uses the following default settings:
- Host:
0.0.0.0 - Port:
8000 - WebSocket Path:
/ws/progress - Static Files: Served from
/static
Docker Support
To run with Docker:
# Build the image
docker build -t bdfr-web-interface .
# Run the container
docker run -p 8000:8000 bdfr-web-interface
Development
Adding New Features
- Backend Changes: Modify
app/main.pyto add new endpoints - Frontend Changes: Update
templates/index.htmlfor UI changes - Styling: Modify
static/css/style.cssfor visual changes - JavaScript: Update
static/js/app.jsfor client-side functionality
WebSocket Integration
The WebSocket connection automatically handles:
- Connection establishment and reconnection
- Progress updates from the server
- Error handling and user notifications
- Real-time UI updates
Form Handling
Both download forms include:
- Input validation
- Loading states
- Success/error notifications
- Automatic form reset on success
Integration with BDFR
Direct BDFR API Integration
This interface uses the direct BDFR API integration, eliminating the need for subprocess console parsing:
/api/download/subreddit- Downloads from subreddits usingBDFRManager.download_subreddit()/api/download/user- Downloads from users usingBDFRManager.download_user()/api/bdfr/status- Returns BDFR system status and capabilities/ws/progress- Provides real-time progress updates via WebSocket
The web interface imports BDFRManager directly from bdfr.api and uses structured progress callbacks for seamless integration.
Migration Notes
Previous Approach (Subprocess-based):
- Used
subprocess.Popento start BDFR CLI - Parsed console output with regex for progress updates
- Required
BDFRRunnerclass for process management - Used
threading.Threadandqueue.Queuefor coordination
Current Approach (Direct API):
- Direct integration with
BDFRManagerfrombdfr.api - Structured
ProgressEventcallbacks instead of console parsing - Thread-safe progress tracking with
ProgressCallbackinterface - No subprocess overhead or console output parsing required
The migration provides better error handling, structured progress events, and eliminates console parsing complexity.
Browser Support
- Modern browsers with WebSocket support
- Chrome 60+
- Firefox 55+
- Safari 11+
- Edge 79+
Security Considerations
- CORS is enabled for all origins (configure for production)
- Input validation on both client and server
- No authentication implemented (add as needed)
- WebSocket connections are not secured (use WSS in production)
Production Deployment
For production deployment:
- Configure CORS for specific origins
- Add authentication/authorization
- Use HTTPS/WSS for secure connections
- Configure proper logging
- Set up reverse proxy (nginx recommended)
- Add rate limiting
- Configure environment variables
Troubleshooting
Common Issues
-
WebSocket Connection Failed:
- Check if the server is running
- Verify firewall settings
- Check browser console for errors
-
Downloads Not Starting:
- Verify BDFR integration is configured
- Check server logs for errors
- Ensure form data is valid
-
Static Files Not Loading:
- Verify static file paths
- Check file permissions
- Ensure proper MIME types
Debug Mode
Run with debug logging:
python main.py --log-level debug
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
License
This project is part of the BDFR ecosystem. See the main project license for details.