Skip to main content

How to work with WebForms Core in Python (Flask framework)

To use WebForms Core, first install WFC package or copy the WebForms class file in this directory to your project. Then create a new View file similar to the one below.

from flask import Flask, request, render_template_string
from WebForms import WebForms, InputPlace 

app = Flask(__name__)

@app.route('/', methods=['GET', 'POST'])
def index():
    if request.method == 'POST' and 'btn_SetBodyValue' in request.form:
        name = request.form['txt_Name']
        background_color = request.form['txt_BackgroundColor']
        font_size = str(request.form['txt_FontSize'])

        form = WebForms()

        form.set_font_size(InputPlace.tag('form'), font_size + 'px')
        form.set_background_color(InputPlace.tag('form'), background_color)
        form.set_disabled(InputPlace.name('btn_SetBodyValue'), True)

        form.add_tag(InputPlace.tag('form'), 'h3')
        form.set_text(InputPlace.tag('h3'), f"Welcome {name}!")

        return form.response()
        
    return render_template_string('''
    <!DOCTYPE html>
    <html>
    <head>
      <title>Using WebForms Core</title>
      <script type="module" src="/static/script/web-forms.js"></script>
    </head>
    <body>
        <form method="post" action="/">
            <label for="txt_Name">Your Name</label>
            <input name="txt_Name" id="txt_Name" type="text" />
            <br>
            <label for="txt_FontSize">Set Font Size</label>
            <input name="txt_FontSize" id="txt_FontSize" type="number" value="16" min="10" max="36" />
            <br>
            <label for="txt_BackgroundColor">Set Background Color</label>
            <input name="txt_BackgroundColor" id="txt_BackgroundColor" type="text" />
            <br>
            <input name="btn_SetBodyValue" type="submit" value="Click to send data" />
        </form>
    </body>
    </html>
    ''')

if __name__ == '__main__':
    app.run(debug=True)

In the upper part of the View file, it is first checked whether the submit button has been clicked or not, if it has been clicked, an instance of the WebForms class is created, then the WebForms methods are called, and then the response method is printed on the screen, and other parts Views are not displayed. Please note that if the submit button is not clicked (initial request), the view page will be displayed completely for the requester.

As you can see, the WebFormsJS script has been added in the header section of the View file above.

The latest version of the WebFormsJS script is available through the link below.

https://github.com/elanatframework/Web_forms/blob/elanat_framework/web-forms.js

Metadata

Release files for WFC 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for WFC 2.1.0
File Size Uploaded
wfc-2.1.0.tar.gz 17.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for WFC 2.1.0
File Interpreter ABI Platform
wfc-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 34.5 kB

Release files / wfc-2.1.0.tar.gz

Download URL wfc-2.1.0.tar.gz
Size 17.3 kB
Tags Source
SHA-256 checksum
How to use checksums
64522c06fc4b49e3b6d417979fad097f76cec3976c3d769d7f985c9bad988c9c
BLAKE2b-256 checksum
How to use checksums
46faafdddddfa7dbde910258774c837f3760f2b52691032a7767dbfbaf1bcada
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / wfc-2.1.0-py3-none-any.whl

Download URL wfc-2.1.0-py3-none-any.whl
Size 17.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
277a2b68fcc9e72ffd2acbe2019dcaad27a7447e75b90f4f7247e21f9228bc7a
BLAKE2b-256 checksum
How to use checksums
faa9c8a2f936977ce65c3ea7cf38b5c50f35789c24835c1cabf00995bc4d5d16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release history Release notifications | RSS feed

2.1.1

2 release files

This release

2.1.0 This release

2 release files

2.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page