-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-script.py
62 lines (47 loc) · 1.46 KB
/
test-script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from datetime import datetime
from lona_picocss.html import HTML, ScrollerPre, Grid, Div, H1, A
from lona_picocss import install_picocss
from lona_dropzone import Dropzone
from lona import App, View
app = App(__file__)
install_picocss(app, debug=True)
@app.route('/')
class DropzoneView(View):
def handle_request(self, request):
self.dropzone = Dropzone(
request=request,
on_add=self.on_add,
on_delete=self.on_delete,
)
self.scroller = ScrollerPre(height='30em')
return HTML(
H1('Dropzone'),
Grid(
Div(
self.dropzone,
),
Div(
self.scroller,
A(
'Bucket URL',
href=self.dropzone.bucket.get_url(),
interactive=False,
target='_blank',
),
),
),
)
def on_add(self, file_names):
# this method gets called whenever a file gets added (uploaded)
self.scroller.append(
f'{datetime.now()}: on_add: {file_names=}\n',
)
self.show()
def on_delete(self, file_names):
# this method gets called whenever a file gets deleted
self.scroller.append(
f'{datetime.now()}: on_delete: {file_names=}\n',
)
self.show()
if __name__ == '__main__':
app.run()