Skip to content

khaliduzzamantanoy/pyftp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PyFTP Movie Server 🎬

Python Flask License Maintenance

A powerful Python-based movie streaming server that provides a sleek web interface for browsing and streaming movies with comprehensive admin management capabilities. Built with Flask and designed for both personal and small-scale commercial use.

✨ Features

  • πŸŽ₯ High-Quality Movie Streaming: Stream movies directly through the web interface with smooth playback
  • πŸ–ΌοΈ Visual Movie Gallery: Beautiful poster displays for enhanced browsing experience
  • πŸ‘¨β€πŸ’Ό Advanced Admin Panel: Secure administrative interface for complete movie management
  • πŸ“± Responsive Design: Fully mobile-friendly interface that works on all devices
  • πŸ”’ Secure Authentication: Robust admin login system with session management
  • πŸ“Š JSON Database: Lightweight, fast movie metadata storage system
  • πŸš€ Production Ready: WSGI compatible with Gunicorn for deployment
  • 🎨 Modern UI/UX: Clean, intuitive interface with custom CSS and JavaScript

πŸ”§ Requirements

  • Python 3.7+
  • Flask 2.3.3+
  • Werkzeug 2.3.7+
  • Gunicorn 21.2.0+ (for production deployment)

See requirements.txt for complete dependency list.

πŸš€ Quick Start

Prerequisites

Ensure you have Python 3.7+ installed on your system.

Installation

  1. Clone the repository

    git clone https://github.com/khaliduzzamantanoy/pyftp.git
    cd pyftp
  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. Access the application

    • Open your browser and navigate to http://localhost:5000
    • For admin access, go to http://localhost:5000/admin

πŸŽ‰ That's it! Your movie server is now running and ready to use.

πŸ’» Usage

Development Mode

Run the application in development mode with hot reload:

python app.py

The server will start on http://localhost:5000 with debug mode enabled.

Production Mode

For production deployment using Gunicorn:

# Basic production run
gunicorn --bind 0.0.0.0:8000 wsgi:app

# Advanced production with multiple workers
gunicorn --bind 0.0.0.0:8000 --workers 4 --timeout 300 wsgi:app

Docker Deployment 🐳

# Build the image
docker build -t pyftp-server .

# Run the container
docker run -p 8000:8000 -v $(pwd)/static/movies:/app/static/movies pyftp-server

πŸ” Admin Panel

Access the powerful admin interface at /admin to manage your movie server:

Admin Features

  • πŸ“Š Dashboard: Overview of total movies, storage usage, and server stats
  • βž• Add Movies: Upload and add new movies with metadata
  • ✏️ Edit Movies: Modify movie information, posters, and descriptions
  • πŸ—‘οΈ Delete Movies: Remove movies and associated files
  • βš™οΈ Server Settings: Configure server parameters and preferences
  • πŸ‘₯ User Management: Handle admin users and permissions
  • πŸ“ˆ Analytics: View streaming statistics and popular content

Default Admin Credentials

  • Username: admin
  • Password: admin

⚠️ Security Notice: Change default credentials immediately after first login!

βš™οΈ Configuration

Environment Variables

Configure your application using environment variables:

# Application Settings
FLASK_ENV=production                    # development or production
SECRET_KEY=your-super-secret-key-here   # Generate a strong secret key
DEBUG=False                             # Enable/disable debug mode

# Admin Settings
ADMIN_USERNAME=your_admin_username      # Custom admin username
ADMIN_PASSWORD=your_secure_password     # Strong admin password

# Server Settings
HOST=0.0.0.0                           # Server host
PORT=5000                              # Server port
MAX_CONTENT_LENGTH=5368709120          # Max upload size (5GB)

# Database Settings
MOVIES_DB_PATH=data/movies.json        # Movies database file path
UPLOAD_FOLDER=static/movies            # Movies upload directory

Custom Configuration

Modify app.py to customize advanced settings:

# Server Configuration
app.config['MAX_CONTENT_LENGTH'] = 5 * 1024 * 1024 * 1024  # 5GB max file size
app.config['UPLOAD_FOLDER'] = 'static/movies'
app.config['ALLOWED_EXTENSIONS'] = {'mp4', 'avi', 'mkv', 'mov'}

# Security Configuration
app.config['SESSION_PERMANENT'] = False
app.config['SESSION_TYPE'] = 'filesystem'

πŸ”Œ API Reference

Public Endpoints

Method Endpoint Description Parameters
GET / Main movie browsing page None
GET /movie/<movie_id> Stream specific movie movie_id: Movie identifier
GET /poster/<movie_id> Get movie poster movie_id: Movie identifier
GET /search Search movies q: Search query

Admin Endpoints

Method Endpoint Description Auth Required
GET /admin Admin login page No
POST /admin/login Admin authentication No
GET /admin/panel Admin dashboard Yes
POST /admin/upload Upload new movie Yes
PUT /admin/movie/<movie_id> Update movie info Yes
DELETE /admin/movie/<movie_id> Delete movie Yes
GET /admin/stats Server statistics Yes

API Response Format

{
  "status": "success|error",
  "data": {...},
  "message": "Response message",
  "timestamp": "2025-06-11T10:30:00Z"
}

πŸ›‘οΈ Security Features

  • πŸ” Session-based Authentication: Secure admin login with session management
  • πŸ›‘οΈ CSRF Protection: Cross-site request forgery protection
  • πŸ“ File Type Validation: Strict file type checking for uploads
  • πŸ”’ Secure File Handling: Safe file upload and storage mechanisms
  • 🧹 Input Sanitization: All user inputs are sanitized and validated
  • 🚫 Path Traversal Protection: Prevents directory traversal attacks
  • πŸ”‘ Secret Key Management: Secure session key configuration

πŸš€ Production Deployment

Option 1: Gunicorn + Nginx

  1. Install Gunicorn

    pip install gunicorn
  2. Create systemd service (/etc/systemd/system/pyftp.service):

    [Unit]
    Description=PyFTP Movie Server
    After=network.target
    
    [Service]
    User=www-data
    Group=www-data
    WorkingDirectory=/path/to/pyftp
    Environment="PATH=/path/to/pyftp/venv/bin"
    ExecStart=/path/to/pyftp/venv/bin/gunicorn --workers 4 --bind unix:pyftp.sock -m 007 wsgi:app
    Restart=always
    
    [Install]
    WantedBy=multi-user.target
  3. Configure Nginx (/etc/nginx/sites-available/pyftp):

    server {
        listen 80;
        server_name your-domain.com;
    
        client_max_body_size 5G;
    
        location / {
            include proxy_params;
            proxy_pass http://unix:/path/to/pyftp/pyftp.sock;
            proxy_read_timeout 300s;
            proxy_connect_timeout 75s;
        }
    
        location /static {
            alias /path/to/pyftp/static;
            expires 1y;
            add_header Cache-Control "public, immutable";
        }
    }

Option 2: Docker Deployment 🐳

  1. Create Dockerfile:

    FROM python:3.9-slim
    
    WORKDIR /app
    
    # Install system dependencies
    RUN apt-get update && apt-get install -y \
        ffmpeg \
        && rm -rf /var/lib/apt/lists/*
    
    # Copy and install Python dependencies
    COPY requirements.txt .
    RUN pip install --no-cache-dir -r requirements.txt
    
    # Copy application code
    COPY . .
    
    # Create non-root user
    RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
    USER appuser
    
    EXPOSE 8000
    CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "4", "wsgi:app"]
  2. Create docker-compose.yml:

    version: "3.8"
    services:
      pyftp:
        build: .
        ports:
          - "8000:8000"
        volumes:
          - ./static/movies:/app/static/movies
          - ./data:/app/data
        environment:
          - FLASK_ENV=production
          - SECRET_KEY=your-production-secret-key
        restart: unless-stopped
  3. Deploy:

    docker-compose up -d

Option 3: Cloud Deployment ☁️

Heroku

# Install Heroku CLI and login
heroku create your-app-name
heroku config:set FLASK_ENV=production
heroku config:set SECRET_KEY=your-secret-key
git push heroku main

AWS EC2

# Launch EC2 instance and connect
sudo apt update && sudo apt install python3-pip nginx
git clone https://github.com/khaliduzzamantanoy/pyftp.git
cd pyftp
pip3 install -r requirements.txt
# Configure nginx and systemd as shown above

🀝 Contributing

We welcome contributions from the community! Here's how you can help:

Ways to Contribute

  • πŸ› Bug Reports: Found a bug? Open an issue with detailed reproduction steps
  • πŸ’‘ Feature Requests: Have an idea? We'd love to hear it!
  • πŸ”§ Code Contributions: Submit pull requests for bug fixes or new features
  • πŸ“– Documentation: Help improve our documentation
  • 🎨 UI/UX Improvements: Make the interface even better

Development Setup

  1. Fork and Clone

    git clone https://github.com/your-username/pyftp.git
    cd pyftp
  2. Create Development Environment

    python -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt
    pip install -r requirements-dev.txt  # Development dependencies
  3. Create Feature Branch

    git checkout -b feature/amazing-new-feature
  4. Make Changes and Test

    python app.py  # Test your changes
  5. Submit Pull Request

    git add .
    git commit -m "Add amazing new feature"
    git push origin feature/amazing-new-feature

Code Style Guidelines

  • Follow PEP 8 for Python code
  • Use meaningful variable and function names
  • Add comments for complex logic
  • Write docstrings for functions and classes
  • Test your changes thoroughly

Pull Request Process

  1. Update documentation if needed
  2. Add tests for new features
  3. Ensure all tests pass
  4. Update the changelog
  5. Request review from maintainers

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for complete details.

πŸ‘¨β€πŸ’» Author & Maintainer

MD Khaliduzzaman Tanoy

πŸ†˜ Support & Help

Getting Help

  • πŸ“š Documentation: Check this README and inline code comments
  • πŸ› Issues: GitHub Issues
  • πŸ“§ Email: Reach out via GitHub for complex issues

Common Issues & Solutions

Movie won't play?

  • Check file format compatibility (MP4 recommended)
  • Verify file permissions in the movies directory
  • Ensure adequate server resources

Admin panel not accessible?

  • Verify admin credentials
  • Check if session is active
  • Clear browser cache and cookies

Upload failing?

  • Check file size limits (default 5GB)
  • Verify available disk space
  • Ensure proper folder permissions

Support This Project

If you find PyFTP Movie Server useful:

  • ⭐ Star this repository on GitHub
  • πŸ› Report bugs and suggest improvements
  • 🀝 Contribute code or documentation
  • πŸ’¬ Share with others who might benefit
  • πŸ“ Write a review or tutorial

πŸ™ Acknowledgments

Special thanks to:

  • Flask Community for the amazing web framework
  • Bootstrap Team for responsive design components
  • Contributors who help improve this project
  • Users who provide valuable feedback and bug reports
  • Open Source Community for inspiration and tools

⭐ If you find this project useful, please consider giving it a star on GitHub! ⭐

Made with ❀️ by MD Khaliduzzaman Tanoy

About

Python-based FTP movie server.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors