Skip to main content

Make simple UIs with bootstrap 4

Project description

Flask Simple UI

To get started you need a simple flask app:

from flask import Flask

app = Flask(__name__)

Attaching a UI is very simple:

from flask_simple_ui import UI

ui = UI(app)

You can also attach it to another root or require a password:

admin = UI(app, login_handler=PasswordHandler("123456"), root="/admin")

An view can be defined like this:

test_form = Form([Text("text", "Text", required=True), Text("text2", "Text2"),
                  ButtonGroup("buttons", [Submit("submit", "Submit")])])


@ui.input("/", test_form, template_args={"title": "sample", "heading": "Sample"})
def test(info, data):
    t_data = []
    for key in data:
        t_data.append([key, data[key]])
    return ui.view(View([Table("table", t_data, numbered=True, head=["key", "data"])]))

You can also return a form again (for @UI.input routes this has to be the same form again) and pass parameters to the template (like: errors (str[]), warnings (str[]) or success (str))

ui.form(
    secret_form,
    template_args={
        "errors": [
            "Some error",
            "Another error"
        ],
        "warnings": [
            "A warnings"
        ],
        "success": "Secret received"
    }
)

You can also use this library for simple outputs:

@ui.route("/", template_args={"title": "sample", "heading": "Sample"})
def test(info):
    return ui.view(View([Table("table", [["key1", "value1"]], numbered=True, head=["key", "data"])]))

For more examples see src/samples/sample.py

Planned

  • CSRF

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for flask-simple-ui, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size flask_simple_ui-0.1.1-py3-none-any.whl (12.7 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size flask-simple-ui-0.1.1.tar.gz (5.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page