A Python tool to generate HTML and CSS with programmable syntax.
Project description
PyFrontKit
A Python DSL for Building Web Views as Executable Code
PyFrontKit is a Python library that lets you build web views using pure Python, producing clean, professional HTML and CSS without replacing or hiding web standards.
It is not a framework — it’s a backend-friendly engine for structure, control, and clarity.
🌟 Why PyFrontKit Exists
Developers often spend hours writing repetitive HTML and CSS. PyFrontKit allows you to:
- Reduce boilerplate while keeping full control
- Generate real, editable HTML and CSS
- Use Python logic (
if/else,for) to shape your page dynamically - Build production-ready pages to disk or directly in memory, with optional inline CSS
Structure first. Automation second. Control always.
💡 What PyFrontKit Is (and Isn’t)
✔ It is:
- A Pythonic DSL for HTML and CSS
- A productivity tool that simplifies repetitive tasks
- A system that produces professional, editable code
- Suitable for static sites, landing pages, and Python-driven frontends
✖ It is not:
- A visual builder
- A framework that hides HTML/CSS
- A layout generator
- A runtime-dependent system
PyFrontKit helps you write less without thinking less.
🧱 Core Concepts
Blocks and Content
- Blocks = HTML elements (
div,section,header, etc.) ctn_parameters = textual content inside a block- IDs are optional; required only for blocks receiving children later
Footer(ctn_p="© 2025 PyFrontKit") # simple block
Footer(id="page_footer") # can receive children later
Text Handling (ContentItems)
- Automatically converts line breaks (
\n) into<br /> - Supports multiple tags (
p,span,h1–h6,strong,em,code,mark) - Full triple-quoted strings supported
🎨 Styling
1️⃣ Inline Styles (Fast Prototyping)
Div(ctn_p="Hello", style="color:red; padding:10px;")
2️⃣ External CSS (Recommended)
PyFrontKit generates selectors in style.css that are editable:
#page_footer {}
section {}
div {}
🎨 Color System (Optional)
CreateColor→ predefined palettes and templatesCreateWithColor→ define custom colors while using templates
Available templates:
simple, classic, soft, darkness, mono, mono_accent, total, total_v2, classic_reverse, dark_reverse, asimetric, enfasis_main
✒️ Typography System (Optional)
- Load custom or Google fonts
- Separate body, header, and footer typography
- Apply styles via CSS, never hardcoded
💻 Disk vs Memory
Disk Mode
Generates files:
index.html
style.css
Memory Mode
Returns a fully-rendered string, ready for frameworks like FastAPI or Flask, optionally with inline CSS for single-response delivery.
doc.create_template() # returns HTML+CSS string
📄 Basic Example
from pyfrontkit import HtmlDoc, Header, Section, Div, Footer
doc = HtmlDoc(title="PyFrontKit Example")
Header(ctn_h1="Welcome to PyFrontKit")
Section(id="content")
content(
Div(ctn_p="This page was generated entirely with Python.")
)
Footer(ctn_p="© 2025 PyFrontKit")
doc.create_document() # writes index.html + style.css
🖼️ Examples
PyFrontKit ships with two professional examples:
| File | Description |
|---|---|
example_1.py |
Landing page with hero sections and grids |
example_2.py |
Multi-section page demonstrating color & typography systems |
Check the
examples/folder to see PyFrontKit in action.
🚀 Use Cases
- Static websites
- Documentation generators
- Landing pages
- UI prototyping
- Teaching HTML & CSS structure
- Python-driven frontend workflows
📦 Installation
pip install pyfrontkit
or
pip install git+https://github.com/Edybrown/pyfrontkit.git
🧪 Production Ready
- Deterministic output
- Tested with
pytest - No runtime dependencies
- Ideal for automation & CI pipelines
👤 Author
Eduardo Antonio Ferrera Rodríguez Focus: Python DSL, frontend structure, automation without abstraction loss, professional output
Licensed under MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyfrontkit-1.1.35.tar.gz.
File metadata
- Download URL: pyfrontkit-1.1.35.tar.gz
- Upload date:
- Size: 31.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91ea4db0a854b32df220c87ba2628803605138f6e9f664b11a9713d3bd5e484e
|
|
| MD5 |
f07359a0ba0d6c9b5c0fd93d43ec2cd4
|
|
| BLAKE2b-256 |
74715966750134d3b332be097ab7b67c7b2eabc89c15336f38ed0aae1daaa9dc
|
File details
Details for the file pyfrontkit-1.1.35-py3-none-any.whl.
File metadata
- Download URL: pyfrontkit-1.1.35-py3-none-any.whl
- Upload date:
- Size: 37.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0rc1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34e3647f2734c608c847e78e763f8367fc558013cf0face69e56d71f92a4362b
|
|
| MD5 |
28fc1f95947ed0d46d3dfa89cc179913
|
|
| BLAKE2b-256 |
a618d0be34ddae99a0785574bd7d522248829c894f0c4df7fe760e601490a530
|