Skip to main content

Web HTML maker in Python - a light web application framework

Project description

WhakerPy - a Web HTML maker in Python

Overview

Whakerpy is a simple library useful to create dynamic HTML content; it's a light web application framework.

Create and manipulate HTML from the power of Python:

  • Easy to learn. Consistent, simple syntax.
  • Flexible and easy usage.
  • Create HTML pages dynamically
  • Can save as static files, and/or
  • Run locally with its httpd server and response "bakery" system.

Author

Copyright (C) 2023 - Brigitte Bigi - develop@sppas.org Laboratoire Parole et Langage, Aix-en-Provence, France

License

This is the implementation of the WhakerPy library, under the terms of the GNU General Public License version 3.

Install WhakerPy

From its repo:

Download the repository and unpack it or clone with git. WhakerPy package includes the following folders and files:

  1. "whakerpy": the source code package
  2. "docs": the documentation of whakerpy in HTML
  3. "tests": unittest of whakerpy source code
  4. "sample":
  5. "etc": etcetera!

From its package:

Download the wheel file and install it in your python environment with:

> python -m pip install dist/<whakerpy.whl>

From pypi.org:

> python -m pip install WhakerPy

Quick Start

Open a Python interpreter and type or paste the following:

>>> from whakerpy.htmlmaker import *
>>> htree = HTMLTree("index")
>>> node = HTMLNode(htree.body_main.identifier, None, "h1", value="this is a title")
>>> htree.body_main.append_child(node)

Render and print the HTML

>>> print(htree.serialize())
<!DOCTYPE html>

<html>
   <head>    </head>
<body>
 <main>
     <h1>
         this is a title
     </h1>
 </main>

</body>
</html>

Add some styling and others

>>> htree.head.title("WhakerPy")
>>> htree.head.meta({"charset": "utf-8"})
>>> htree.head.link(rel="icon", href="/static/favicon.ico")
>>> htree.head.link(rel="stylesheet", href="nice.css", link_type="text/css")

Add page copyright in the footer

>>> copyreg = HTMLNode(htree.body_footer.identifier, "copyright", "p",
>>>                    attributes={"class": "copyright", "role": "none"},
>>>                    value="Copyright &copy; 2023 My Self")
>>> htree.body_footer.append_child(copyreg)

Let's view the result in your favorite web browser

>>> import webbrowser
>>> file_whakerpy = htree.serialize_to_file('file.html')
>>> webbrowser.open_new_tab(file_whakerpy)

Create a web application frontend with dynamic HTML content

For a quick start, see the file sample.py. It shows a very simple solution to create a server that can handle dynamic content. This content is created from a custom BaseResponseRecipe() object, available in the file samples/response.py. The response is the interface between a local back-end python application and the web front-end.

For a more complex example of an already in-used web frontend, see: https://sourceforge.net/p/sppas/code/ci/master/tree/sppas/ui/swapp/app_setup/setupmaker.py.

Projects using WhakerPy

WhakerPy was initially developed within SPPAS http://sppas/org; it was extracted from its original software by its author to lead its own life as standalone package. The "setup" of SPPAS is entirely based on whakerpy API, and it's website too.

Other projects:

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

WhakerPy-0.1.tar.gz (45.0 kB view details)

Uploaded Source

Built Distribution

WhakerPy-0.1-py3-none-any.whl (29.7 kB view details)

Uploaded Python 3

File details

Details for the file WhakerPy-0.1.tar.gz.

File metadata

  • Download URL: WhakerPy-0.1.tar.gz
  • Upload date:
  • Size: 45.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for WhakerPy-0.1.tar.gz
Algorithm Hash digest
SHA256 d82c73a247c6060726625f1e4eacf9b239474708004447e83dea2c27cf0312a4
MD5 1ef246cb1a4a8997d4c3bf428514f567
BLAKE2b-256 472d01008afe054aafcd9e17a7bcb43a01c29027a59fba71ccdc2aa7fb7e3da0

See more details on using hashes here.

File details

Details for the file WhakerPy-0.1-py3-none-any.whl.

File metadata

  • Download URL: WhakerPy-0.1-py3-none-any.whl
  • Upload date:
  • Size: 29.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for WhakerPy-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1b7cadc3f39a130f03eff2f78f899e8a3e026191cfe1316820e1abd60ed47a10
MD5 2c74e6404cd93035092dca7a597cbc39
BLAKE2b-256 eb30c09d74abd7226e5e2fd9d8af14546924b7b090764cf1214b271d7a7f9e94

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