-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improves multiuploads example and prepares release
- Loading branch information
1 parent
77cf8f4
commit 2ec4e6a
Showing
2 changed files
with
27 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |