-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.py
executable file
·55 lines (47 loc) · 1.08 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/Library/Frameworks/Python.framework/Versions/2.7/bin/python
print "Content-Type: application/json\r\n\r\n"
'''
print "<html>"
print "<head>"
print "<title>Event Model Demo</title>"
print "</head>"
print "<body>"
'''
try:
import json,sys
import cgi, cgitb
cgitb.enable()
import logging
logging.basicConfig(filename='/tmp/warcs/errors.log')
import eventUtils as utils
warcDir = '/tmp/warcs/'
form = cgi.FieldStorage()
#if 'uploadedFile' in form:
warcf = form['uploadedFile'].file
warcfn = form['uploadedFile'].filename
logging.debug(warcfn)
warcFile = warcDir + warcfn
f = open(warcFile,"wb")
f.write(warcf.read())
f.close()
#else:
# warcf = open(warcDir + 'test.warc.gz')
# warcFile = warcDir + warcfn
#print "file="+warcFile +",name="+warcfn
out = {}
out['file']=warcFile
out['name']=warcfn
out['width']=0
out['height']=0
out['type']=""
out['uploadType']=""
out['size']=0
print json.dumps(out)
#print "</body>"
#print "</html>"
except:
logging.exception('')
logging.debug('error!!')
#print sys.exc_info()[0]
print sys.exc_info()[1]
print sys.exc_info()[2]