Skip to main content

The Back-End Part of WebForms Core Technology

Project description

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

To use WebForms Core, first 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

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

wfc-2.0.0.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

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

wfc-2.0.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file wfc-2.0.0.tar.gz.

File metadata

  • Download URL: wfc-2.0.0.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for wfc-2.0.0.tar.gz
Algorithm Hash digest
SHA256 fdeae77b134c51c5b1f8eca075ae492c4e194b7ab461d0e569485e6cc974ee73
MD5 7714f98b07d55e84237993b771a85f7e
BLAKE2b-256 29525b7ae7caa859ff4c04846f0bbe53a7416b9933441987e2b65a008bf9a3f4

See more details on using hashes here.

File details

Details for the file wfc-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: wfc-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for wfc-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7fc7122c0aedea7254a8b435cccada134dc995856c35fdf7c89691f4ed1c8c9d
MD5 c62fe3093c7473fba09b610b957c567c
BLAKE2b-256 475d60b11baa8765f9fb24298fc26c32de65c7845e45566451f38315c6d7d178

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