Skip to main content

HTML in Pure Python

Project description

pyhtmlify

Downloads pyhtmlify CI

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 use it. This package isn't completely finished, as we are still adding heaps of stuff and more HTML tags to this project.

Just quickly as well, currently you are unable to use the doctype and html tags as they are bugged and I do not know why. If you would like to add these tags, do so manually in the html file. If you would like to help fix this bug, please feel free too.

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 pyhtmlify will pick it up.

For pyhtmlify 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, pyhtmlify comes with a pyhtmlify command to use. In the terminal, to generate html code for all the html-*.py files, run

pyhtmlify generate -f folder -i input_file -n file_name

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.

The -i flag specifies the file you would like to generate html for. This defaults to the whole directory

The -n flag specifies the output files name. This defaults to the same name as the py file.

There is also a find command

pyhtmlify find -f folder

This command finds all possible files to generate and tell you the file and the file path to it. If the -f flag isnt used, it will scan the entire working directory.

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.8.tar.gz (23.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyhtmlify-0.1.8-py3-none-any.whl (23.2 kB view details)

Uploaded Python 3

File details

Details for the file pyhtmlify-0.1.8.tar.gz.

File metadata

  • Download URL: pyhtmlify-0.1.8.tar.gz
  • Upload date:
  • Size: 23.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for pyhtmlify-0.1.8.tar.gz
Algorithm Hash digest
SHA256 2ace999f3ca55f89d1ba0ff3485799ecac04a12e0756d66d6e15f0c04546b920
MD5 f44de274cdcbbf36bb9b613b4c8ac3a6
BLAKE2b-256 51255ff28cd37d05accb08ff3a11fd10719a64a8861abbb2070dfedba23613b9

See more details on using hashes here.

File details

Details for the file pyhtmlify-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: pyhtmlify-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 23.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for pyhtmlify-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 df03e00228bbd8ddc6c1f2aa23d7e90395f107c65c38f62909db239430529a57
MD5 5de765fce42bca98bd28350cfbf49a9f
BLAKE2b-256 3e0266206751145557bde0988f1f94f8925d95c975b4f284f128d45194b5cb39

See more details on using hashes here.

Supported by

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