Skip to main content

Write HTML with Pythonic Code

Project description

https://img.shields.io/github/license/mashape/apistatus.svg https://badge.fury.io/py/pytohtml.svg

Installation

$ pip install pytohtml

Example

https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/597237/436215da-f815-4473-687e-7fc21b04bab3.gif

QR-Code Generator Source Code.

https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/597237/40173212-8f2e-0e4e-c924-3140d6ff1722.gif

Simple Chat Source Code.

Syntax

from py2html.elements import html, head, body, meta, title, h1


print(
    html(lang="en")[
        head[
            meta(charset="UTF-8"),
            meta({"http-equiv": "X-UA-Compatible", "content": "IE=edge"}),
            meta(name="viewport", content="width=device-width, initial-scale=1.0"),
            title["py2html"]
        ],
        body[
            h1[
                "Hello, Py2HTML!"
            ]
        ]
    ].render()
)

*formatted output

<html lang="en">
<head>
<meta charset="UTF-8"></meta>
<meta http-equiv="X-UA-Compatible" content="IE=edge"></meta>
<meta name="viewport" content="width=device-width, initial-scale=1.0"></meta>
<title>py2html</title>
</head>
<body>
<h1>Hello, Py2HTML!</h1>
</body>
</html>

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

pytohtml-1.2.6.tar.gz (59.1 kB view hashes)

Uploaded Source

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