Skip to content

Commit

Permalink
improves multiuploads example and prepares release
Browse files Browse the repository at this point in the history
  • Loading branch information
WolfgangFahl committed Aug 25, 2022
1 parent 77cf8f4 commit 2ec4e6a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
44 changes: 26 additions & 18 deletions examples/multiuploads.py
Original file line number Diff line number Diff line change
@@ -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)

2 changes: 1 addition & 1 deletion justpy/__init__.py
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 2ec4e6a

Please sign in to comment.