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
Metadata
Release files for pyfrontkit 1.1.35
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyfrontkit-1.1.35.tar.gz | 31.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyfrontkit-1.1.35-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 69.5 kB
Release files / pyfrontkit-1.1.35.tar.gz
| Download URL | pyfrontkit-1.1.35.tar.gz |
|---|---|
| Size | 31.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
91ea4db0a854b32df220c87ba2628803605138f6e9f664b11a9713d3bd5e484e
|
|
BLAKE2b-256 checksum How to use checksums |
74715966750134d3b332be097ab7b67c7b2eabc89c15336f38ed0aae1daaa9dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.0rc1
|
Release files / pyfrontkit-1.1.35-py3-none-any.whl
| Download URL | pyfrontkit-1.1.35-py3-none-any.whl |
|---|---|
| Size | 37.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
34e3647f2734c608c847e78e763f8367fc558013cf0face69e56d71f92a4362b
|
|
BLAKE2b-256 checksum How to use checksums |
a618d0be34ddae99a0785574bd7d522248829c894f0c4df7fe760e601490a530
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.0rc1
|