File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -6,8 +6,7 @@ def getImgBytes(imgParam):
66 if re .match (r'^http' , imgParam ) != None :
77 resp = request .urlopen (imgParam )
88 img_bytes = bytearray (resp .read ())
9- pass
10- elif re .match (r'(\.jpg|\.jpeg|\.png|\.gif)$' , imgParam ) != None :
9+ elif re .search (r'(\.jpg|\.jpeg|\.png|\.gif)$' , imgParam ) != None :
1110 with open (imgParam , 'rb' ) as f :
1211 img_bytes = f .read ()
1312 else :
@@ -30,7 +29,11 @@ def app(environ, start_response):
3029 if "action" in params .keys ():
3130 action = params ["action" ][0 ]
3231 if action == "getCode" :
33- return [str .encode (deCodeImg (getImgBytes (params ["img" ][0 ])))]
32+ try :
33+ result = deCodeImg (getImgBytes (params ["img" ][0 ]))
34+ except :
35+ return [b'Image data is incorrect!' ]
36+ return [str .encode (result )]
3437 return [b'1' ]
3538
3639
You can’t perform that action at this time.
0 commit comments