Skip to main content

Component based html generator for flask

Project description

Flask-HTML

Flask GitHub top language LICENCE Odya

HTML generator for Flask applications. Make your HTML code more readable and easier to maintain.

Installation

pip install flask_html

Usage

from flask_html import Page, Head
from flask_html.tags import Style, Body, Div, P
from flask import request
@app.route('/')
def index():
    head = Head('Title', [],['https://code.jquery.com/jquery-3.6.1.min.js'], [{"meta_property": "value"}])
    page = Page(head)
    page.register_js("""
                    $(document).ready(function(){
                        $("body").append("<p>hello world</p>");
                    })
                     
                     """)
    body = Body(page, styles=Style(color="red", padding_top="15px"),classes=['class1', 'class2'], id='body_id',elements=[
        Div(styles=Style(margin="10px"), classes=['class1', 'class2'], id='div_id', elements=[
            P(styles=Style(color="blue"), classes=['class1', 'class2'], id='p_id', elements=[
                "Hello World"
            ])
        ])
    ])
    return page.render(body, request)

Elements

Example of Div elements

"""Div HTML element

Args:
    styles (Style, optional): Inline css styles. Defaults to None.
    classes (List[str], optional): List of class names. Defaults to [].
    id (str, optional): Unique ID. Defaults to None.
    elements (List[object], optional): List of child elements. Defaults to [].
    props (Dict[str, str], optional): Additional tag properties. Defaults to {}.
"""
Div(styles=None, classes=[], id=None, elements=[], props={})

All elements

  • Div
  • P
  • B
  • H1-H6
  • A
  • Img
  • Span
  • Ul
  • Li
  • Button
  • Input
  • Form
  • Header
  • Footer
  • Nav

License

This project is licensed under the MIT License (see the LICENSE file for details).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Flask-HTML-1.0.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

Flask_HTML-1.0.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file Flask-HTML-1.0.0.tar.gz.

File metadata

  • Download URL: Flask-HTML-1.0.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.0

File hashes

Hashes for Flask-HTML-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0f025d313b7b7cd3618276c722984bef17e21e6c3e6aff8a54501a11565ceea6
MD5 7fbdec8e837dc0499de2396b3f5917cf
BLAKE2b-256 94ab4ab5f922fc7b5dd1e5e2859cf66f07eb6a619b425b820d53229b1747bfed

See more details on using hashes here.

File details

Details for the file Flask_HTML-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: Flask_HTML-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.0

File hashes

Hashes for Flask_HTML-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2fab0bdd6d05f31c482db38320f32c6924427fa690e2a1ba87126dedfb2d0c06
MD5 e18fbfccbfb87f69a45bbc21f54043fc
BLAKE2b-256 c3d563756bb0c97bbbf353bbad25a8f91f3258414da178ecea6bfc070afcdc9f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page