WEP is a lightweight server-side template engine and micro-framework that lets you embed native Python directly inside HTML using
.wep
files and<wep>
tags. Inspired by PHP, WEP enables rapid prototyping and AI-powered dynamic web content β without the complexity of separate frontend/backend stacks or REST APIs.
- β
Write Python directly inside HTML using
<wep>...</wep>
blocks - β
Output content using the simple
echo()
function - β Built with Flask under the hood
- β Minimal setup β no frontend frameworks or build tools needed
- β Ideal for quick demos, server-rendered sites, teaching, and prototyping AI apps
- β
Supports special variables like
_GET
,_POST
,_FILES
,GLOBAL
, andSESSION
inside<wep>
blocks for handling requests and session data
- Python 3.7+
git
pip
(Python package manager)uv
(modern Python package manager β install withpip install uv
)
-
Clone this repository:
git clone https://github.com/prodev717/web-embedded-python.git
-
Navigate to the project folder:
cd web-embedded-python
-
Install
uv
if you donβt already have it:pip install uv
-
Install dependencies:
uv add flask
-
Run the server:
uv run main.py
-
Visit your app:
http://localhost:8000
web-embedded-python/
βββ public/
β βββ index.wep # Homepage with embedded Python
β βββ demo.wep # Optional additional demo
β βββ style.css # Any static assets (CSS, JS, images)
βββ main.py # Flask-based server
.wep
files are HTML with embedded Python blocks inside <wep>...</wep>
tags:
<!DOCTYPE html> <html> <head><title>WEP Example</title></head> <body> <h1>Hello from WEP</h1> <wep> echo("<p>This is Python inside HTML!</p>") import sys echo(f"<pre>Python version: {sys.version}</pre>") for i in range(3): echo(f"<p>Loop: {i}</p>") </wep> </body> </html>
- Python code inside
<wep>
must be zero-indented (start from column 0). - Nested
<wep>
tags are not supported. - Use the global
echo()
function to write content to the HTML output. - Use standard Python imports as needed.
.wep
files are best for lightweight server-side logic, not heavy lifting.
Need extra packages (e.g., requests
, openai
, pandas
)?
Just run:
uv add package_name
Found a bug or have an idea? Feel free to open an issue or submit a pull request. Contributions welcome!
Licensed under the MIT License.
WEP is inspired by PHP's simplicity, adapted for the Python ecosystem. Itβs perfect for Python devs who want to prototype fast β without learning a new frontend stack.