Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: about 2 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 (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-25T11:54:54.000Z (12 months ago)
- Last Synced: 2024-08-09T03:27:14.717Z (5 months 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
![main](https://github.com/micheltlutz/Winged-Python/actions/workflows/python-package.yml/badge.svg?branch=main)
[![codecov](https://codecov.io/gh/micheltlutz/Winged-Python/graph/badge.svg?token=UvaQd65VVD)](https://codecov.io/gh/micheltlutz/Winged-Python)
[![codebeat badge](https://codebeat.co/badges/b0a28fb9-ffba-4214-980f-a4333781f98f)](https://codebeat.co/projects/github-com-micheltlutz-winged-python-main)
[![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com)
[![PyPI version](https://badge.fury.io/py/winged-python.svg)](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 StringdivC = 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 headerstable.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 HTMLResponsefrom 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