pyframe-web


Namepyframe-web JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/PyFrameWeb/PyFrame
SummaryRevolutionary Full-Stack Python Web Framework - Write React-like components in pure Python
upload_time2025-08-09 18:39:44
maintainerNone
docs_urlNone
authorPyFrame Team
requires_python>=3.8
licenseMIT
keywords web framework python react components frontend backend full-stack reactive hot-reload transpiler javascript
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">
  <img src="PyFrame-logo.png" alt="PyFrame Logo" width="500" height="500"/>
  
  # PyFrame - Full-Stack Python Web Framework

  **A modern, reactive web framework that allows developers to write both frontend and backend entirely in Python, with automatic compilation to efficient JavaScript for the browser.**
</div>

[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## 🚀 **What Makes PyFrame Special**

PyFrame revolutionizes web development by eliminating the traditional frontend/backend divide. Write your entire application in Python - from reactive UI components to database models - and PyFrame handles the rest.

```python
from pyframe import PyFrameApp, Component, Model, Field, FieldType

# Define your data model
class User(Model):
    name: str = Field(FieldType.STRING, max_length=100)
    email: str = Field(FieldType.EMAIL, unique=True)
    # ↳ Automatically generates database tables, migrations, and REST APIs!

# Create reactive UI components in Python
class UserProfile(Component):
    def render(self):
        user = self.props.get("user")
        return f"""
        <div class="profile">
            <h1>Welcome, {user.name}!</h1>
            <p>Email: {user.email}</p>
        </div>
        """
        # ↳ Automatically compiles to JavaScript for the browser!

# Set up your app
app = PyFrameApp()

@app.component_route("/profile/<user_id>")
class ProfilePage(UserProfile):
    pass

app.run()  # 🎉 Full-stack app running!
```

## ✨ **Key Features**

### 🐍 **Unified Python Development**
- Write frontend UI components entirely in Python
- Automatic compilation to optimized JavaScript
- Reactive state management with Python syntax
- No JavaScript, TypeScript, or build tools required

### 🔄 **Real-Time by Default**
- Built-in WebSocket and Server-Sent Events support
- Automatic data synchronization between server and clients
- Optimistic UI updates with conflict resolution
- Live component updates without page refreshes

### 📊 **Zero-Boilerplate Data Layer**
- Define models with Python classes and type hints
- Automatic database schema generation and migrations
- Auto-generated REST and GraphQL APIs
- Built-in validation and form generation

### 📱 **Context-Aware Adaptivity**
- Automatic device type and network speed detection
- Adaptive content delivery and optimization
- User preference detection (dark mode, reduced motion)
- Progressive enhancement for accessibility

### 🔌 **Plugin-Based Architecture**
- Lightweight core (~10-20KB) with optional plugins
- Built-in plugins for auth, caching, analytics
- Easy custom plugin development
- Hook system for extending functionality

### ⚡ **Modern Development Experience**
- Hot module replacement with file watching
- Zero-config development server
- Detailed error reporting and debugging
- AI-assisted code suggestions (optional)

## 🏗️ **Architecture Overview**

PyFrame uses a layered architecture where each component can be used independently:

```
┌─────────────────────────────────────────────────────────────┐
│  🎨 Frontend (Python → JavaScript)                         │
│  • Reactive components written in Python                   │
│  • Automatic compilation to efficient JavaScript           │
│  • Client-side hydration and state management              │
└─────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│  ⚙️  Core Runtime                                          │
│  • Component lifecycle management                          │
│  • Routing and navigation                                  │
│  • Server-side rendering (SSR)                            │
└─────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│  🗄️  Data Layer                                           │
│  • Model definitions with automatic migrations             │
│  • Auto-generated REST/GraphQL APIs                       │
│  • Built-in validation and relationships                   │
└─────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│  🔌 Plugin System                                          │
│  • Authentication and authorization                        │
│  • Caching and performance optimization                    │
│  • Analytics and monitoring                               │
└─────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────┐
│  🌐 Server & Deployment                                    │
│  • Context-aware adaptive rendering                        │
│  • Multiple deployment targets (serverless, edge, VPS)     │
│  • Development server with hot reload                      │
└─────────────────────────────────────────────────────────────┘
```

## 🚀 **Quick Start**

### Installation

```bash
pip install pyframe-web
```

### Using the CLI (Recommended)

PyFrame includes a command-line tool to help you get started quickly:

```bash
# Create a new project
pyframe-web create my-awesome-app
cd my-awesome-app

# Install dependencies
pip install -r requirements.txt

# Run the development server
python main.py
# or
pyframe-web run
```

Your app will be available at `http://localhost:3000` with hot reload enabled!

### Create Your First App Manually

```python
# app.py
from pyframe import PyFrameApp, Component, StatefulComponent

class Counter(StatefulComponent):
    def __init__(self, props=None, children=None):
        super().__init__(props, children)
        self.set_state("count", 0)
    
    def increment(self):
        count = self.get_state("count", 0)
        self.set_state("count", count + 1)
    
    def render(self):
        count = self.get_state("count", 0)
        return f"""
        <div>
            <h1>Count: {count}</h1>
            <button onclick="this.component.increment()">
                Click me!
            </button>
        </div>
        """

app = PyFrameApp()

@app.component_route("/")
class HomePage(Counter):
    pass

if __name__ == "__main__":
    app.run()
```

### Run Your App

```bash
python app.py
```

Visit `http://localhost:3000` to see your reactive counter in action! 🎉

## 📖 **Learn by Example**

### **Reactive Components**

```python
class TodoList(StatefulComponent):
    def __init__(self, props=None, children=None):
        super().__init__(props, children)
        self.set_state("todos", [])
        self.set_state("input_value", "")
    
    def add_todo(self):
        input_value = self.get_state("input_value", "")
        if input_value.strip():
            todos = self.get_state("todos", [])
            todos.append({"id": len(todos), "text": input_value, "done": False})
            self.set_state("todos", todos)
            self.set_state("input_value", "")
    
    def toggle_todo(self, todo_id):
        todos = self.get_state("todos", [])
        for todo in todos:
            if todo["id"] == todo_id:
                todo["done"] = not todo["done"]
        self.set_state("todos", todos)
    
    def render(self):
        todos = self.get_state("todos", [])
        input_value = self.get_state("input_value", "")
        
        todo_items = ""
        for todo in todos:
            checked = "checked" if todo["done"] else ""
            todo_items += f"""
            <li>
                <input type="checkbox" {checked} 
                       onchange="this.component.toggle_todo({todo['id']})">
                <span class="{'done' if todo['done'] else ''}">{todo['text']}</span>
            </li>
            """
        
        return f"""
        <div class="todo-app">
            <h1>Todo List</h1>
            <div class="add-todo">
                <input type="text" value="{input_value}" 
                       placeholder="Add a todo..."
                       onchange="this.component.set_state('input_value', this.value)">
                <button onclick="this.component.add_todo()">Add</button>
            </div>
            <ul class="todo-list">{todo_items}</ul>
        </div>
        """
```

### **Data Models with Auto-Generated APIs**

```python
from pyframe.data.models import Model, Field, FieldType
from datetime import datetime

class User(Model):
    username: str = Field(FieldType.STRING, unique=True, max_length=50)
    email: str = Field(FieldType.EMAIL, unique=True)
    first_name: str = Field(FieldType.STRING, max_length=50, required=False)
    last_name: str = Field(FieldType.STRING, max_length=50, required=False)
    is_active: bool = Field(FieldType.BOOLEAN, default=True)
    created_at: datetime = Field(FieldType.DATETIME, auto_now_add=True)

class Post(Model):
    title: str = Field(FieldType.STRING, max_length=200)
    content: str = Field(FieldType.TEXT)
    author_id: str = Field(FieldType.UUID, foreign_key="User")
    published: bool = Field(FieldType.BOOLEAN, default=False)
    tags: list = Field(FieldType.JSON, default=list)

# Automatically generates:
# GET /api/users - List users
# POST /api/users - Create user  
# GET /api/users/:id - Get user
# PUT /api/users/:id - Update user
# DELETE /api/users/:id - Delete user
# (Same for posts)

# Use in Python:
user = User.create(username="john", email="john@example.com")
post = Post.create(title="Hello World", content="...", author_id=user.id)
```

### **Real-Time Live Updates**

```python
class ChatRoom(StatefulComponent):
    def __init__(self, props=None, children=None):
        super().__init__(props, children)
        self.set_state("messages", [])
        self.set_state("input_value", "")
        
        # Subscribe to real-time updates
        room_id = props.get("room_id", "general")
        live_sync_manager.subscribe_to_channel(f"chat:{room_id}")
    
    def send_message(self):
        input_value = self.get_state("input_value", "")
        if input_value.strip():
            message = ChatMessage.create(
                content=input_value,
                room_id=self.props.get("room_id"),
                user_id=self.props.get("user_id")
            )
            # ↳ Automatically broadcasts to all connected clients!
            self.set_state("input_value", "")
    
    def render(self):
        messages = self.get_state("messages", [])
        input_value = self.get_state("input_value", "")
        
        message_list = ""
        for msg in messages:
            message_list += f"""
            <div class="message">
                <strong>{msg['username']}:</strong> {msg['content']}
            </div>
            """
        
        return f"""
        <div class="chat-room">
            <div class="messages">{message_list}</div>
            <div class="input-area">
                <input type="text" value="{input_value}"
                       onchange="this.component.set_state('input_value', this.value)"
                       onkeypress="if(event.key==='Enter') this.component.send_message()">
                <button onclick="this.component.send_message()">Send</button>
            </div>
        </div>
        """
```

### **Plugins and Authentication**

```python
from pyframe.plugins.auth_plugin import AuthPlugin, require_auth

# Configure authentication
app.register_plugin(AuthPlugin({
    "jwt_secret": "your-secret-key",
    "password_min_length": 8
}))

# Protected routes
@app.component_route("/dashboard")
@require_auth
class Dashboard(Component):
    def render(self):
        user = self.props.get("user")
        return f"""
        <div class="dashboard">
            <h1>Welcome, {user.username}!</h1>
            <p>This is your private dashboard.</p>
        </div>
        """

# Login component
class LoginForm(StatefulComponent):
    def __init__(self, props=None, children=None):
        super().__init__(props, children)
        self.set_state("username", "")
        self.set_state("password", "")
        self.set_state("loading", False)
    
    async def handle_login(self):
        self.set_state("loading", True)
        
        username = self.get_state("username", "")
        password = self.get_state("password", "")
        
        # Make API call to login endpoint
        response = await fetch("/auth/login", {
            "method": "POST",
            "headers": {"Content-Type": "application/json"},
            "body": json.dumps({"username": username, "password": password})
        })
        
        if response.ok:
            # Redirect to dashboard
            window.location.href = "/dashboard"
        else:
            self.set_state("loading", False)
            # Show error message
    
    def render(self):
        username = self.get_state("username", "")
        password = self.get_state("password", "")
        loading = self.get_state("loading", False)
        
        return f"""
        <form class="login-form" onsubmit="this.component.handle_login(); return false;">
            <h2>Login</h2>
            <input type="text" placeholder="Username" value="{username}"
                   onchange="this.component.set_state('username', this.value)">
            <input type="password" placeholder="Password" value="{password}"
                   onchange="this.component.set_state('password', this.value)">
            <button type="submit" {'disabled' if loading else ''}>
                {'Logging in...' if loading else 'Login'}
            </button>
        </form>
        """
```

## 🌟 **Live Demo**

Explore a complete blog application built with PyFrame:

```bash
git clone https://github.com/pyframe/pyframe.git
cd pyframe/examples/blog_app
pip install -r requirements.txt
python main.py
```

Visit `http://localhost:3000` to see:
- Reactive Python components
- Real-time comments
- Auto-generated APIs
- Adaptive rendering
- Authentication system
- Hot reload in action

## 📚 **Documentation**

### **Core Concepts**
- [Components and State Management](docs/components.md)
- [Routing and Navigation](docs/routing.md)
- [Data Models and APIs](docs/data-layer.md)
- [Real-Time Features](docs/realtime.md)

### **Advanced Topics**
- [Plugin Development](docs/plugins.md)
- [Custom Hooks](docs/hooks.md)
- [Deployment Guide](docs/deployment.md)
- [Performance Optimization](docs/performance.md)

### **API Reference**
- [Component API](docs/api/components.md)
- [Model API](docs/api/models.md)
- [Plugin API](docs/api/plugins.md)
- [Server API](docs/api/server.md)

## 🔧 **Development**

### **Requirements**
- Python 3.8+
- Modern web browser with JavaScript enabled

### **Dependencies**
- `asyncio` - Asynchronous programming
- `websockets` - Real-time communication
- `watchdog` - File system monitoring
- `PyJWT` - JSON Web Tokens

### **Development Setup**

```bash
# Clone the repository
git clone https://github.com/pyframe/pyframe.git
cd pyframe

# Install dependencies
pip install -r requirements.txt

# Run tests
python -m pytest

# Run the example app
cd examples/blog_app
python main.py
```

## 🚢 **Deployment**

PyFrame applications can be deployed anywhere Python runs:

### **Traditional Servers**
```python
from pyframe.deployment.wsgi import create_wsgi_app

# WSGI for Apache, Gunicorn, uWSGI
application = create_wsgi_app(app)
```

### **ASGI Servers**
```python
from pyframe.deployment.asgi import create_asgi_app

# ASGI for Uvicorn, Daphne, Hypercorn
application = create_asgi_app(app)
```

### **Serverless Functions**
```python
# AWS Lambda, Vercel, Netlify Functions
def lambda_handler(event, context):
    return app.handle_serverless_request(event, context)
```

### **Edge Computing**
```python
# Cloudflare Workers, Deno Deploy
app.configure_for_edge_deployment()
```

## 🤝 **Contributing**

We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.

### **Development Philosophy**
- **Python-First**: Everything should be writable in Python
- **Zero Config**: Sensible defaults with optional customization
- **Performance**: Fast development, fast runtime
- **Accessibility**: Progressive enhancement and WCAG compliance
- **Developer Experience**: Great error messages and debugging tools

## 📄 **License**

MIT License - see the [LICENSE](LICENSE) file for details.

## 🙏 **Acknowledgments**

PyFrame is inspired by:
- **React** - Component-based architecture
- **Django** - Batteries-included philosophy  
- **FastAPI** - Modern Python web framework design
- **Next.js** - Full-stack development experience
- **Phoenix LiveView** - Real-time server-rendered UI

## 💬 **Community**

- [GitHub Discussions](https://github.com/pyframe/pyframe/discussions) - Questions and ideas
- [Discord Server](https://discord.gg/pyframe) - Real-time chat
- [Twitter](https://twitter.com/pyframe) - Updates and announcements
- [Examples](https://github.com/PyFrameWeb/PyFrame/tree/main/examples) - Sample applications and tutorials

---

**Ready to build the future of web development with Python?** 🐍✨

```bash
pip install pyframe-web
```

[Get Started](https://github.com/PyFrameWeb/PyFrame/blob/main/docs/core-concepts.md) | [Examples](https://github.com/PyFrameWeb/PyFrame/tree/main/examples) | [API Docs](https://github.com/PyFrameWeb/PyFrame/tree/main/docs/api-reference)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/PyFrameWeb/PyFrame",
    "name": "pyframe-web",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "web framework, python, react, components, frontend, backend, full-stack, reactive, hot-reload, transpiler, javascript",
    "author": "PyFrame Team",
    "author_email": "PyFrame Team <pyframe@example.com>",
    "download_url": "https://files.pythonhosted.org/packages/14/bc/1683bbd4a445f3ee748df88a96c81b459fb84a313ed7c2e93706e7249fe2/pyframe_web-0.1.0.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\r\n  <img src=\"PyFrame-logo.png\" alt=\"PyFrame Logo\" width=\"500\" height=\"500\"/>\r\n  \r\n  # PyFrame - Full-Stack Python Web Framework\r\n\r\n  **A modern, reactive web framework that allows developers to write both frontend and backend entirely in Python, with automatic compilation to efficient JavaScript for the browser.**\r\n</div>\r\n\r\n[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\r\n\r\n## \ud83d\ude80 **What Makes PyFrame Special**\r\n\r\nPyFrame revolutionizes web development by eliminating the traditional frontend/backend divide. Write your entire application in Python - from reactive UI components to database models - and PyFrame handles the rest.\r\n\r\n```python\r\nfrom pyframe import PyFrameApp, Component, Model, Field, FieldType\r\n\r\n# Define your data model\r\nclass User(Model):\r\n    name: str = Field(FieldType.STRING, max_length=100)\r\n    email: str = Field(FieldType.EMAIL, unique=True)\r\n    # \u21b3 Automatically generates database tables, migrations, and REST APIs!\r\n\r\n# Create reactive UI components in Python\r\nclass UserProfile(Component):\r\n    def render(self):\r\n        user = self.props.get(\"user\")\r\n        return f\"\"\"\r\n        <div class=\"profile\">\r\n            <h1>Welcome, {user.name}!</h1>\r\n            <p>Email: {user.email}</p>\r\n        </div>\r\n        \"\"\"\r\n        # \u21b3 Automatically compiles to JavaScript for the browser!\r\n\r\n# Set up your app\r\napp = PyFrameApp()\r\n\r\n@app.component_route(\"/profile/<user_id>\")\r\nclass ProfilePage(UserProfile):\r\n    pass\r\n\r\napp.run()  # \ud83c\udf89 Full-stack app running!\r\n```\r\n\r\n## \u2728 **Key Features**\r\n\r\n### \ud83d\udc0d **Unified Python Development**\r\n- Write frontend UI components entirely in Python\r\n- Automatic compilation to optimized JavaScript\r\n- Reactive state management with Python syntax\r\n- No JavaScript, TypeScript, or build tools required\r\n\r\n### \ud83d\udd04 **Real-Time by Default**\r\n- Built-in WebSocket and Server-Sent Events support\r\n- Automatic data synchronization between server and clients\r\n- Optimistic UI updates with conflict resolution\r\n- Live component updates without page refreshes\r\n\r\n### \ud83d\udcca **Zero-Boilerplate Data Layer**\r\n- Define models with Python classes and type hints\r\n- Automatic database schema generation and migrations\r\n- Auto-generated REST and GraphQL APIs\r\n- Built-in validation and form generation\r\n\r\n### \ud83d\udcf1 **Context-Aware Adaptivity**\r\n- Automatic device type and network speed detection\r\n- Adaptive content delivery and optimization\r\n- User preference detection (dark mode, reduced motion)\r\n- Progressive enhancement for accessibility\r\n\r\n### \ud83d\udd0c **Plugin-Based Architecture**\r\n- Lightweight core (~10-20KB) with optional plugins\r\n- Built-in plugins for auth, caching, analytics\r\n- Easy custom plugin development\r\n- Hook system for extending functionality\r\n\r\n### \u26a1 **Modern Development Experience**\r\n- Hot module replacement with file watching\r\n- Zero-config development server\r\n- Detailed error reporting and debugging\r\n- AI-assisted code suggestions (optional)\r\n\r\n## \ud83c\udfd7\ufe0f **Architecture Overview**\r\n\r\nPyFrame uses a layered architecture where each component can be used independently:\r\n\r\n```\r\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\r\n\u2502  \ud83c\udfa8 Frontend (Python \u2192 JavaScript)                         \u2502\r\n\u2502  \u2022 Reactive components written in Python                   \u2502\r\n\u2502  \u2022 Automatic compilation to efficient JavaScript           \u2502\r\n\u2502  \u2022 Client-side hydration and state management              \u2502\r\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\r\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\r\n\u2502  \u2699\ufe0f  Core Runtime                                          \u2502\r\n\u2502  \u2022 Component lifecycle management                          \u2502\r\n\u2502  \u2022 Routing and navigation                                  \u2502\r\n\u2502  \u2022 Server-side rendering (SSR)                            \u2502\r\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\r\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\r\n\u2502  \ud83d\uddc4\ufe0f  Data Layer                                           \u2502\r\n\u2502  \u2022 Model definitions with automatic migrations             \u2502\r\n\u2502  \u2022 Auto-generated REST/GraphQL APIs                       \u2502\r\n\u2502  \u2022 Built-in validation and relationships                   \u2502\r\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\r\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\r\n\u2502  \ud83d\udd0c Plugin System                                          \u2502\r\n\u2502  \u2022 Authentication and authorization                        \u2502\r\n\u2502  \u2022 Caching and performance optimization                    \u2502\r\n\u2502  \u2022 Analytics and monitoring                               \u2502\r\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\r\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\r\n\u2502  \ud83c\udf10 Server & Deployment                                    \u2502\r\n\u2502  \u2022 Context-aware adaptive rendering                        \u2502\r\n\u2502  \u2022 Multiple deployment targets (serverless, edge, VPS)     \u2502\r\n\u2502  \u2022 Development server with hot reload                      \u2502\r\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\r\n```\r\n\r\n## \ud83d\ude80 **Quick Start**\r\n\r\n### Installation\r\n\r\n```bash\r\npip install pyframe-web\r\n```\r\n\r\n### Using the CLI (Recommended)\r\n\r\nPyFrame includes a command-line tool to help you get started quickly:\r\n\r\n```bash\r\n# Create a new project\r\npyframe-web create my-awesome-app\r\ncd my-awesome-app\r\n\r\n# Install dependencies\r\npip install -r requirements.txt\r\n\r\n# Run the development server\r\npython main.py\r\n# or\r\npyframe-web run\r\n```\r\n\r\nYour app will be available at `http://localhost:3000` with hot reload enabled!\r\n\r\n### Create Your First App Manually\r\n\r\n```python\r\n# app.py\r\nfrom pyframe import PyFrameApp, Component, StatefulComponent\r\n\r\nclass Counter(StatefulComponent):\r\n    def __init__(self, props=None, children=None):\r\n        super().__init__(props, children)\r\n        self.set_state(\"count\", 0)\r\n    \r\n    def increment(self):\r\n        count = self.get_state(\"count\", 0)\r\n        self.set_state(\"count\", count + 1)\r\n    \r\n    def render(self):\r\n        count = self.get_state(\"count\", 0)\r\n        return f\"\"\"\r\n        <div>\r\n            <h1>Count: {count}</h1>\r\n            <button onclick=\"this.component.increment()\">\r\n                Click me!\r\n            </button>\r\n        </div>\r\n        \"\"\"\r\n\r\napp = PyFrameApp()\r\n\r\n@app.component_route(\"/\")\r\nclass HomePage(Counter):\r\n    pass\r\n\r\nif __name__ == \"__main__\":\r\n    app.run()\r\n```\r\n\r\n### Run Your App\r\n\r\n```bash\r\npython app.py\r\n```\r\n\r\nVisit `http://localhost:3000` to see your reactive counter in action! \ud83c\udf89\r\n\r\n## \ud83d\udcd6 **Learn by Example**\r\n\r\n### **Reactive Components**\r\n\r\n```python\r\nclass TodoList(StatefulComponent):\r\n    def __init__(self, props=None, children=None):\r\n        super().__init__(props, children)\r\n        self.set_state(\"todos\", [])\r\n        self.set_state(\"input_value\", \"\")\r\n    \r\n    def add_todo(self):\r\n        input_value = self.get_state(\"input_value\", \"\")\r\n        if input_value.strip():\r\n            todos = self.get_state(\"todos\", [])\r\n            todos.append({\"id\": len(todos), \"text\": input_value, \"done\": False})\r\n            self.set_state(\"todos\", todos)\r\n            self.set_state(\"input_value\", \"\")\r\n    \r\n    def toggle_todo(self, todo_id):\r\n        todos = self.get_state(\"todos\", [])\r\n        for todo in todos:\r\n            if todo[\"id\"] == todo_id:\r\n                todo[\"done\"] = not todo[\"done\"]\r\n        self.set_state(\"todos\", todos)\r\n    \r\n    def render(self):\r\n        todos = self.get_state(\"todos\", [])\r\n        input_value = self.get_state(\"input_value\", \"\")\r\n        \r\n        todo_items = \"\"\r\n        for todo in todos:\r\n            checked = \"checked\" if todo[\"done\"] else \"\"\r\n            todo_items += f\"\"\"\r\n            <li>\r\n                <input type=\"checkbox\" {checked} \r\n                       onchange=\"this.component.toggle_todo({todo['id']})\">\r\n                <span class=\"{'done' if todo['done'] else ''}\">{todo['text']}</span>\r\n            </li>\r\n            \"\"\"\r\n        \r\n        return f\"\"\"\r\n        <div class=\"todo-app\">\r\n            <h1>Todo List</h1>\r\n            <div class=\"add-todo\">\r\n                <input type=\"text\" value=\"{input_value}\" \r\n                       placeholder=\"Add a todo...\"\r\n                       onchange=\"this.component.set_state('input_value', this.value)\">\r\n                <button onclick=\"this.component.add_todo()\">Add</button>\r\n            </div>\r\n            <ul class=\"todo-list\">{todo_items}</ul>\r\n        </div>\r\n        \"\"\"\r\n```\r\n\r\n### **Data Models with Auto-Generated APIs**\r\n\r\n```python\r\nfrom pyframe.data.models import Model, Field, FieldType\r\nfrom datetime import datetime\r\n\r\nclass User(Model):\r\n    username: str = Field(FieldType.STRING, unique=True, max_length=50)\r\n    email: str = Field(FieldType.EMAIL, unique=True)\r\n    first_name: str = Field(FieldType.STRING, max_length=50, required=False)\r\n    last_name: str = Field(FieldType.STRING, max_length=50, required=False)\r\n    is_active: bool = Field(FieldType.BOOLEAN, default=True)\r\n    created_at: datetime = Field(FieldType.DATETIME, auto_now_add=True)\r\n\r\nclass Post(Model):\r\n    title: str = Field(FieldType.STRING, max_length=200)\r\n    content: str = Field(FieldType.TEXT)\r\n    author_id: str = Field(FieldType.UUID, foreign_key=\"User\")\r\n    published: bool = Field(FieldType.BOOLEAN, default=False)\r\n    tags: list = Field(FieldType.JSON, default=list)\r\n\r\n# Automatically generates:\r\n# GET /api/users - List users\r\n# POST /api/users - Create user  \r\n# GET /api/users/:id - Get user\r\n# PUT /api/users/:id - Update user\r\n# DELETE /api/users/:id - Delete user\r\n# (Same for posts)\r\n\r\n# Use in Python:\r\nuser = User.create(username=\"john\", email=\"john@example.com\")\r\npost = Post.create(title=\"Hello World\", content=\"...\", author_id=user.id)\r\n```\r\n\r\n### **Real-Time Live Updates**\r\n\r\n```python\r\nclass ChatRoom(StatefulComponent):\r\n    def __init__(self, props=None, children=None):\r\n        super().__init__(props, children)\r\n        self.set_state(\"messages\", [])\r\n        self.set_state(\"input_value\", \"\")\r\n        \r\n        # Subscribe to real-time updates\r\n        room_id = props.get(\"room_id\", \"general\")\r\n        live_sync_manager.subscribe_to_channel(f\"chat:{room_id}\")\r\n    \r\n    def send_message(self):\r\n        input_value = self.get_state(\"input_value\", \"\")\r\n        if input_value.strip():\r\n            message = ChatMessage.create(\r\n                content=input_value,\r\n                room_id=self.props.get(\"room_id\"),\r\n                user_id=self.props.get(\"user_id\")\r\n            )\r\n            # \u21b3 Automatically broadcasts to all connected clients!\r\n            self.set_state(\"input_value\", \"\")\r\n    \r\n    def render(self):\r\n        messages = self.get_state(\"messages\", [])\r\n        input_value = self.get_state(\"input_value\", \"\")\r\n        \r\n        message_list = \"\"\r\n        for msg in messages:\r\n            message_list += f\"\"\"\r\n            <div class=\"message\">\r\n                <strong>{msg['username']}:</strong> {msg['content']}\r\n            </div>\r\n            \"\"\"\r\n        \r\n        return f\"\"\"\r\n        <div class=\"chat-room\">\r\n            <div class=\"messages\">{message_list}</div>\r\n            <div class=\"input-area\">\r\n                <input type=\"text\" value=\"{input_value}\"\r\n                       onchange=\"this.component.set_state('input_value', this.value)\"\r\n                       onkeypress=\"if(event.key==='Enter') this.component.send_message()\">\r\n                <button onclick=\"this.component.send_message()\">Send</button>\r\n            </div>\r\n        </div>\r\n        \"\"\"\r\n```\r\n\r\n### **Plugins and Authentication**\r\n\r\n```python\r\nfrom pyframe.plugins.auth_plugin import AuthPlugin, require_auth\r\n\r\n# Configure authentication\r\napp.register_plugin(AuthPlugin({\r\n    \"jwt_secret\": \"your-secret-key\",\r\n    \"password_min_length\": 8\r\n}))\r\n\r\n# Protected routes\r\n@app.component_route(\"/dashboard\")\r\n@require_auth\r\nclass Dashboard(Component):\r\n    def render(self):\r\n        user = self.props.get(\"user\")\r\n        return f\"\"\"\r\n        <div class=\"dashboard\">\r\n            <h1>Welcome, {user.username}!</h1>\r\n            <p>This is your private dashboard.</p>\r\n        </div>\r\n        \"\"\"\r\n\r\n# Login component\r\nclass LoginForm(StatefulComponent):\r\n    def __init__(self, props=None, children=None):\r\n        super().__init__(props, children)\r\n        self.set_state(\"username\", \"\")\r\n        self.set_state(\"password\", \"\")\r\n        self.set_state(\"loading\", False)\r\n    \r\n    async def handle_login(self):\r\n        self.set_state(\"loading\", True)\r\n        \r\n        username = self.get_state(\"username\", \"\")\r\n        password = self.get_state(\"password\", \"\")\r\n        \r\n        # Make API call to login endpoint\r\n        response = await fetch(\"/auth/login\", {\r\n            \"method\": \"POST\",\r\n            \"headers\": {\"Content-Type\": \"application/json\"},\r\n            \"body\": json.dumps({\"username\": username, \"password\": password})\r\n        })\r\n        \r\n        if response.ok:\r\n            # Redirect to dashboard\r\n            window.location.href = \"/dashboard\"\r\n        else:\r\n            self.set_state(\"loading\", False)\r\n            # Show error message\r\n    \r\n    def render(self):\r\n        username = self.get_state(\"username\", \"\")\r\n        password = self.get_state(\"password\", \"\")\r\n        loading = self.get_state(\"loading\", False)\r\n        \r\n        return f\"\"\"\r\n        <form class=\"login-form\" onsubmit=\"this.component.handle_login(); return false;\">\r\n            <h2>Login</h2>\r\n            <input type=\"text\" placeholder=\"Username\" value=\"{username}\"\r\n                   onchange=\"this.component.set_state('username', this.value)\">\r\n            <input type=\"password\" placeholder=\"Password\" value=\"{password}\"\r\n                   onchange=\"this.component.set_state('password', this.value)\">\r\n            <button type=\"submit\" {'disabled' if loading else ''}>\r\n                {'Logging in...' if loading else 'Login'}\r\n            </button>\r\n        </form>\r\n        \"\"\"\r\n```\r\n\r\n## \ud83c\udf1f **Live Demo**\r\n\r\nExplore a complete blog application built with PyFrame:\r\n\r\n```bash\r\ngit clone https://github.com/pyframe/pyframe.git\r\ncd pyframe/examples/blog_app\r\npip install -r requirements.txt\r\npython main.py\r\n```\r\n\r\nVisit `http://localhost:3000` to see:\r\n- Reactive Python components\r\n- Real-time comments\r\n- Auto-generated APIs\r\n- Adaptive rendering\r\n- Authentication system\r\n- Hot reload in action\r\n\r\n## \ud83d\udcda **Documentation**\r\n\r\n### **Core Concepts**\r\n- [Components and State Management](docs/components.md)\r\n- [Routing and Navigation](docs/routing.md)\r\n- [Data Models and APIs](docs/data-layer.md)\r\n- [Real-Time Features](docs/realtime.md)\r\n\r\n### **Advanced Topics**\r\n- [Plugin Development](docs/plugins.md)\r\n- [Custom Hooks](docs/hooks.md)\r\n- [Deployment Guide](docs/deployment.md)\r\n- [Performance Optimization](docs/performance.md)\r\n\r\n### **API Reference**\r\n- [Component API](docs/api/components.md)\r\n- [Model API](docs/api/models.md)\r\n- [Plugin API](docs/api/plugins.md)\r\n- [Server API](docs/api/server.md)\r\n\r\n## \ud83d\udd27 **Development**\r\n\r\n### **Requirements**\r\n- Python 3.8+\r\n- Modern web browser with JavaScript enabled\r\n\r\n### **Dependencies**\r\n- `asyncio` - Asynchronous programming\r\n- `websockets` - Real-time communication\r\n- `watchdog` - File system monitoring\r\n- `PyJWT` - JSON Web Tokens\r\n\r\n### **Development Setup**\r\n\r\n```bash\r\n# Clone the repository\r\ngit clone https://github.com/pyframe/pyframe.git\r\ncd pyframe\r\n\r\n# Install dependencies\r\npip install -r requirements.txt\r\n\r\n# Run tests\r\npython -m pytest\r\n\r\n# Run the example app\r\ncd examples/blog_app\r\npython main.py\r\n```\r\n\r\n## \ud83d\udea2 **Deployment**\r\n\r\nPyFrame applications can be deployed anywhere Python runs:\r\n\r\n### **Traditional Servers**\r\n```python\r\nfrom pyframe.deployment.wsgi import create_wsgi_app\r\n\r\n# WSGI for Apache, Gunicorn, uWSGI\r\napplication = create_wsgi_app(app)\r\n```\r\n\r\n### **ASGI Servers**\r\n```python\r\nfrom pyframe.deployment.asgi import create_asgi_app\r\n\r\n# ASGI for Uvicorn, Daphne, Hypercorn\r\napplication = create_asgi_app(app)\r\n```\r\n\r\n### **Serverless Functions**\r\n```python\r\n# AWS Lambda, Vercel, Netlify Functions\r\ndef lambda_handler(event, context):\r\n    return app.handle_serverless_request(event, context)\r\n```\r\n\r\n### **Edge Computing**\r\n```python\r\n# Cloudflare Workers, Deno Deploy\r\napp.configure_for_edge_deployment()\r\n```\r\n\r\n## \ud83e\udd1d **Contributing**\r\n\r\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.\r\n\r\n### **Development Philosophy**\r\n- **Python-First**: Everything should be writable in Python\r\n- **Zero Config**: Sensible defaults with optional customization\r\n- **Performance**: Fast development, fast runtime\r\n- **Accessibility**: Progressive enhancement and WCAG compliance\r\n- **Developer Experience**: Great error messages and debugging tools\r\n\r\n## \ud83d\udcc4 **License**\r\n\r\nMIT License - see the [LICENSE](LICENSE) file for details.\r\n\r\n## \ud83d\ude4f **Acknowledgments**\r\n\r\nPyFrame is inspired by:\r\n- **React** - Component-based architecture\r\n- **Django** - Batteries-included philosophy  \r\n- **FastAPI** - Modern Python web framework design\r\n- **Next.js** - Full-stack development experience\r\n- **Phoenix LiveView** - Real-time server-rendered UI\r\n\r\n## \ud83d\udcac **Community**\r\n\r\n- [GitHub Discussions](https://github.com/pyframe/pyframe/discussions) - Questions and ideas\r\n- [Discord Server](https://discord.gg/pyframe) - Real-time chat\r\n- [Twitter](https://twitter.com/pyframe) - Updates and announcements\r\n- [Examples](https://github.com/PyFrameWeb/PyFrame/tree/main/examples) - Sample applications and tutorials\r\n\r\n---\r\n\r\n**Ready to build the future of web development with Python?** \ud83d\udc0d\u2728\r\n\r\n```bash\r\npip install pyframe-web\r\n```\r\n\r\n[Get Started](https://github.com/PyFrameWeb/PyFrame/blob/main/docs/core-concepts.md) | [Examples](https://github.com/PyFrameWeb/PyFrame/tree/main/examples) | [API Docs](https://github.com/PyFrameWeb/PyFrame/tree/main/docs/api-reference)\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Revolutionary Full-Stack Python Web Framework - Write React-like components in pure Python",
    "version": "0.1.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/PyFrameWeb/PyFrame/issues",
        "Changelog": "https://github.com/PyFrameWeb/PyFrame/blob/main/CHANGELOG.md",
        "Documentation": "https://github.com/PyFrameWeb/PyFrame/blob/main/README.md",
        "Homepage": "https://github.com/PyFrameWeb/PyFrame",
        "Repository": "https://github.com/PyFrameWeb/PyFrame"
    },
    "split_keywords": [
        "web framework",
        " python",
        " react",
        " components",
        " frontend",
        " backend",
        " full-stack",
        " reactive",
        " hot-reload",
        " transpiler",
        " javascript"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d2a6a7e8282a589ab6707f8dd3c3f6b91be940af4563cce62132187816b717fb",
                "md5": "c417f8bd2d5f8c949ff569ffe01c6872",
                "sha256": "fda2dc83809479ddd93f0bd264aa8513c4ae27205d6831563e1e36f52dcea993"
            },
            "downloads": -1,
            "filename": "pyframe_web-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c417f8bd2d5f8c949ff569ffe01c6872",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 98454,
            "upload_time": "2025-08-09T18:39:43",
            "upload_time_iso_8601": "2025-08-09T18:39:43.142325Z",
            "url": "https://files.pythonhosted.org/packages/d2/a6/a7e8282a589ab6707f8dd3c3f6b91be940af4563cce62132187816b717fb/pyframe_web-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "14bc1683bbd4a445f3ee748df88a96c81b459fb84a313ed7c2e93706e7249fe2",
                "md5": "6b02da287d86c7c4bd398a1d41c1c027",
                "sha256": "55e884f1fd49b7c493938d17b12ef10fe7dd2e43647e9f0e2568ed124afc7f21"
            },
            "downloads": -1,
            "filename": "pyframe_web-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "6b02da287d86c7c4bd398a1d41c1c027",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 122144,
            "upload_time": "2025-08-09T18:39:44",
            "upload_time_iso_8601": "2025-08-09T18:39:44.827932Z",
            "url": "https://files.pythonhosted.org/packages/14/bc/1683bbd4a445f3ee748df88a96c81b459fb84a313ed7c2e93706e7249fe2/pyframe_web-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-09 18:39:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "PyFrameWeb",
    "github_project": "PyFrame",
    "github_not_found": true,
    "lcname": "pyframe-web"
}
        
Elapsed time: 1.60597s