-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathan_upload.py
39 lines (36 loc) · 1.02 KB
/
an_upload.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
# -*- coding: utf-8 -*-
import wuy
class index(wuy.Window):
"""
<script>
function mydragover(e) {
e.target.style.background = "red";
e.preventDefault()
}
function mydragend(e) {
e.target.style.background = "white";
}
function mydrop(e) {
e.target.style.background = "white";
for(var f of e.dataTransfer.files) {
var reader = new FileReader();
reader.onload = function (ee) {
wuy.upload(f.name,ee.target.result)
};
// reader.readAsDataURL(f);
reader.readAsText(f);
}
e.preventDefault()
}
</script>
<body
ondragover="mydragover(event)"
ondragleave="mydragend(event)"
ondragend="mydragend(event)"
ondrop="mydrop(event)">drop on me</body>
"""
def upload(self,name,content):
# here, on server side : save the file 'name', with the text 'content',
print("server:",name,content)
if __name__=="__main__":
index()