https://github.com/micheltlutz/winged-python
Python HTML Made Simple and Powerful
https://github.com/micheltlutz/winged-python
dsl framework html html-generator-python library modular python
Last synced: 12 months ago
JSON representation
Python HTML Made Simple and Powerful
- Host: GitHub
- URL: https://github.com/micheltlutz/winged-python
- Owner: micheltlutz
- License: mit
- Created: 2023-11-18T17:40:48.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-25T11:54:54.000Z (about 2 years ago)
- Last Synced: 2025-03-27T17:51:57.558Z (about 1 year ago)
- Topics: dsl, framework, html, html-generator-python, library, modular, python
- Language: Python
- Homepage: https://linktr.ee/micheltlutz
- Size: 101 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# Winged-Python

[](https://codecov.io/gh/micheltlutz/Winged-Python)
[](https://codebeat.co/projects/github-com-micheltlutz-winged-python-main)
[](https://houndci.com)
[](https://badge.fury.io/py/winged-python)
# =============
Winged-Python is an innovative Domain-Specific Language (DSL) library for efficient HTML writing in Python. Mirroring its Swift counterpart, Winged-Python is based on the DSL concept, focusing on simplification and specificity in HTML generation. Using the Composite design pattern, the library enables developers to construct HTML structures in a logical, organized, and reusable manner.
This library is created to be fully independent, not requiring integration with specific server frameworks or front-end libraries. This offers developers the freedom to use Winged-Python across a variety of projects, from simple static pages to complex web applications, keeping the code clean, readable, and efficient.
## PyPI Releases Page
https://pypi.org/project/winged-python/
- [Releases Page]([https://pypi.org/manage/project/winged-python/releases/](https://pypi.org/project/winged-python/))
## Install
```bash
pip install winged-python==0.1.0
```
## Simple Usage Example
```python
from winged.HTML.div import Div
from winged.HTML.h import H
from winged.HTML.table import Table
from winged.HTML.string import String
divC = Div(("class", "container"))
h = H("1")
h.add(String("Hello World"))
divC.add(h)
table = Table()
table.add_table_headers(["Name", "Age", "Height", "Location"]) # Define headers
table.add_row()
table.add_in_row(String("John"))
table.add_in_row(String("25"))
table.add_in_row(String("1.80"))
table.add_in_row(String("New York"))
table.add_row()
table.add_in_row(String("Maria"))
table.add_in_row(String("23"))
table.add_in_row(String("1.50"))
table.add_in_row(String("New Jersey"))
divC.add(table)
print(divC.generate())
```
## Output
```html
Hello World
Name
Age
Height
Location
John
25
1.80
New York
Maria
23
1.50
New Jersey
```
## Usage with FastAPI Render
```python
from fastapi import FastAPI
from fastapi.responses import HTMLResponse
from winged.HTML.div import Div
from winged.HTML.h import H
from winged.HTML.string import String
@app.get('/', response_class=HTMLResponse)
async def home():
divC = Div(("class", "container"))
h = H("1")
h.add(String("Hello World"))
divC.add(h)
return divC.get_string() # Return HTML String
```
## Contributing
To contribute, it's simple, follow the guidelines below to prepare your development environment
## Create environment
User OS terminal or IDE terminal
### Linux or macOS
```bash
python3 -m venv venv
```
```bash
source venv/bin/activate
```
### Windows
```bash
.\venv\Scripts\activate.bat
```
```bash
.\venv\Scripts\activate.ps1`
```
## Install dependencies
```bash
python3 -m pip install -r requirements.txt
```
## Run tests
```bash
pytest
```
## TODO
- [ ] Make documentation with Sphinx