Skip to main content

Fork of Eel with Vite HMR support for modern web development

Project description

Vit3l

PyPI version PyPI Downloads Python License

Vit3l is a fork of Eel that adds support for external web servers, enabling modern development workflows with Vite HMR (Hot Module Replacement).

What's New

  • External URL Support: Connect to any external web server (Vite, Webpack, etc.)
  • Vite HMR: Full support for Hot Module Replacement
  • Modern Development: Use TypeScript, SCSS, PostCSS, and other modern tools
  • Backward Compatible: All existing Eel functionality preserved
  • WebSocket Communication: Python ↔ JavaScript communication via WebSocket

📦 Installation

Using pip

pip install Vit3l

Using uv (recommended)

uv add Vit3l

With Jinja2 templates

pip install Vit3l[jinja2]
# or
uv add "Vit3l[jinja2]"

🎯 Quick Start

Traditional Eel (still works)

import vit3l as eel

eel.init('web')
eel.start('index.html')  # Runs on localhost:8000

New: External URL Mode

import vit3l as eel

@eel.expose
def say_hello(name):
    return f'Hello {name}!'

eel.init('web')
eel.start('http://localhost:5173', external_url='http://localhost:5173')

JavaScript (same as Eel)

const result = await eel.say_hello("World")();
console.log(result); // "Hello World!"

Vite Integration

1. Setup Vite project

npm create vite@latest my-eel-app
cd my-eel-app
npm install

2. Configure Vite (vite.config.js)

import { defineConfig } from "vite";

export default defineConfig({
  server: {
    port: 5173,
    cors: true,
  },
});

3. Add Eel to HTML

<!DOCTYPE html>
<html>
  <head>
    <title>Vite + Vit3l</title>
  </head>
  <body>
    <h1>Hello from Vite + Vit3l!</h1>
    <button onclick="callPython()">Call Python</button>

    <!-- Connect to Eel WebSocket server -->
    <script src="http://localhost:8000/eel.js"></script>
    <script>
      function callPython() {
        eel.say_hello("from Vite!")();
      }
    </script>
  </body>
</html>

4. Python script

import vit3l as eel

@eel.expose
def say_hello(message):
    print(f"Hello {message}")
    return f"Python received: {message}"

eel.init('src')  # Your Vite source folder
eel.start('http://localhost:5173', external_url='http://localhost:5173')

5. Run both servers

# Terminal 1: Vite dev server
npm run dev

# Terminal 2: Python script
python app.py

Examples

# External URL with custom settings
eel.start(
    'http://localhost:5173',
    external_url='http://localhost:5173',
    mode='chrome',
    port=8000,
    block=True
)

# Multiple URLs
eel.start(
    'http://localhost:5173',
    'http://localhost:3000',
    external_url='http://localhost:5173'
)

External URL Mode

  1. Vite Server: Serves static files with HMR on port 5173
  2. Eel WebSocket Server: Runs on port 8000 for Python ↔ JavaScript communication
  3. Browser: Connects to both servers
  4. Result: Modern development with full Eel functionality

Troubleshooting

WebSocket Connection Issues

// Check WebSocket status in browser console
console.log("WebSocket state:", eel._websocket.readyState);
// 0 = CONNECTING, 1 = OPEN, 2 = CLOSING, 3 = CLOSED

CORS Errors

Ensure Vite is configured with CORS enabled:

// vite.config.js
export default defineConfig({
  server: {
    cors: true,
  },
});

Port Conflicts

Change Eel WebSocket port if 8000 is occupied:

eel.start('http://localhost:5173', external_url='http://localhost:5173', port=8001)

License

MIT License - see LICENSE file for details.

Acknowledgments

  • Original Eel project by Chris Knott

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vit3l-0.21.0.tar.gz (20.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vit3l-0.21.0-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file vit3l-0.21.0.tar.gz.

File metadata

  • Download URL: vit3l-0.21.0.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for vit3l-0.21.0.tar.gz
Algorithm Hash digest
SHA256 0ac81e10554ac65029e35daa165fb64e6e60cddcdf3a13b7fc056dd91b888333
MD5 de49c9ec5414cb88ece5df81ff85ce38
BLAKE2b-256 1097f1f4ce4c3478a56d1287d7dfc1d8a3840e8785267fa0caa0ac612b09ac17

See more details on using hashes here.

File details

Details for the file vit3l-0.21.0-py3-none-any.whl.

File metadata

  • Download URL: vit3l-0.21.0-py3-none-any.whl
  • Upload date:
  • Size: 21.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for vit3l-0.21.0-py3-none-any.whl
Algorithm Hash digest
SHA256 585dab02def989ed23e07c0a398db93db571f43a99286647058cf5d81085abb2
MD5 cb6a67a3932f41ffd2b5242d1ae10b16
BLAKE2b-256 f470794bb349f35363c254cd661f587b2de8116d4ad954d4318aee7ea4f7003c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page