Skip to main content

HTML in Pure Python

Project description

pyhtmlify

pyhtmlify is a Python package that allows you to write HTML code with Pure Python. This package was mainly made for the osd Project for simplicity. Heres how to do it. This package isn't completely finished, as we are still adding heaps of stuff and more HTML tags to this project.

1. Installation

You can install pyhtml using pip

pip install pyhtmlify

This will install the latest version of pyhtmlify.

2. How to use

pyhtmlify is quite easy to use. It is similar to html, but without all of the <> and other things involved. To do so, make a python file starting with html- and pyhtml will pick it up.

For pyhtml to pick up the file to generate the html code for you, you need to have a index function inside of your script. Like this for example:

import pyhtmlify.HTMLTags.tags as ph

def index():
    return ph.div(
        ph.h1("Welcome to My Website"),
        ph.input(type="text", placeholder="Enter your name"),
    )

That is all you need for the script side. Now onto the html conversion

3. PY to HTML Conversion

To convert python index functions into html documents, pyhtml comes with a pyhtml command to use. In the terminal, to generate html code for all the html- files, run

pyhtmlify generate -f folder

The -f flag specifies the output folder, and there are some other flags and commands that are coming up. However, you you dont use the -f flag, the program automatically defaults to /html. All file names of the html files are the same name as the python script.

4. Contribution

If you would like to contribute to this project, please check out the issues and contact me at peggundev@gmail.com, or come check out osd and join the discord community!

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

pyhtmlify-0.1.6.tar.gz (19.0 kB view hashes)

Uploaded Source

Built Distribution

pyhtmlify-0.1.6-py3-none-any.whl (18.4 kB view hashes)

Uploaded Python 3

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