urlo upload as js function

This commit is contained in:
Ville Rantanen
2018-03-15 16:04:24 +02:00
parent 86c855285c
commit 167c58d127
5 changed files with 92 additions and 38 deletions

View File

@@ -5,16 +5,22 @@ try:
from urllib.request import pathname2url
from urllib.request import URLopener
from urllib.request import urlparse
from urllib.error import HTTPError
except ImportError:
from urllib import pathname2url
from urllib import URLopener
from urlparse import urlparse
from urllib2 import HTTPError
def download_url(url,filename):
downloader = URLopener()
downloader.retrieve(url, filename)
return
try:
downloader.retrieve(url, filename)
except HTTPError as e:
return (False, ("%s %s"%(e.code,e.reason), e.code))
return (True, ("OK", 200 ))
def file_date_human(num):
return datetime.fromtimestamp(