diff --git a/examples/multiuploads.py b/examples/multiuploads.py index fd22c488..11a0997c 100644 --- a/examples/multiuploads.py +++ b/examples/multiuploads.py @@ -1,22 +1,30 @@ -from justpy import * +from justpy import Form, Input, Li, Ol, WebPage +# see https://github.com/elimintz/justpy/pull/401 +def handle_submit(_c, msg): + ''' + handle submission of a multi upload + ''' + fl=msg.page.file_list + fl.components.clear() + for fd in msg.form_data: + if "files" in fd: + for f in fd["files"]: + Li(text=f"File uploaded: {f['name']} of {len(f['file_content'])}", a=fl) -def handle_submit(c, msg): - fl=msg.page.file_list - fl.components.clear() - for fd in msg.form_data: - if "files" in fd: - for f in fd["files"]: - Li(text=f"File uploaded: {f['name']} of {len(f['file_content'])}", a=fl) - -def p1(): - wp=WebPage() - f=Form(submit=handle_submit, a=wp) - Input(name="f1", type="file", a=f) - Input(name="f2", type="file", a=f) - Input(type="submit", value="OK", a=f) - wp.file_list=Ol(a=wp) - return wp +def multiupload(): + ''' + show a multi upload + ''' + wp=WebPage() + f=Form(submit=handle_submit, a=wp) + Input(name="f1", type="file", a=f) + Input(name="f2", type="file", a=f) + Input(type="submit", value="OK", a=f) + wp.file_list=Ol(a=wp) + return wp WebPage.tailwind=False -justpy(p1, start_server=(__name__=="__main__")) +from examples.basedemo import Demo +Demo('multi uploads demo',multiupload) + diff --git a/justpy/__init__.py b/justpy/__init__.py index 2f771e72..e53ae8ef 100644 --- a/justpy/__init__.py +++ b/justpy/__init__.py @@ -1,4 +1,4 @@ """JustPy is an object-oriented, component based, high-level Python Web Framework that requires no front-end programming""" from .justpy import * -__version__ = "0.2.5" +__version__ = "0.2.6"