fix web request server. fixes #1455
This commit is contained in:
26
lib/util.py
26
lib/util.py
@@ -524,3 +524,29 @@ class StoreDict(dict):
|
||||
if key in self.keys():
|
||||
dict.pop(self, key)
|
||||
self.save()
|
||||
|
||||
|
||||
|
||||
|
||||
def check_www_dir(rdir):
|
||||
# rewrite index.html every time
|
||||
import urllib, urlparse, shutil, os
|
||||
if not os.path.exists(rdir):
|
||||
os.mkdir(rdir)
|
||||
index = os.path.join(rdir, 'index.html')
|
||||
src = os.path.join(os.path.dirname(__file__), 'www', 'index.html')
|
||||
shutil.copy(src, index)
|
||||
files = [
|
||||
"https://code.jquery.com/jquery-1.9.1.min.js",
|
||||
"https://raw.githubusercontent.com/davidshimjs/qrcodejs/master/qrcode.js",
|
||||
"https://code.jquery.com/ui/1.10.3/jquery-ui.js",
|
||||
"https://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"
|
||||
]
|
||||
for URL in files:
|
||||
path = urlparse.urlsplit(URL).path
|
||||
filename = os.path.basename(path)
|
||||
path = os.path.join(rdir, filename)
|
||||
if not os.path.exists(path):
|
||||
print_error("downloading ", URL)
|
||||
urllib.urlretrieve(URL, path)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user