diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-08-17 20:08:20 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-08-17 20:08:20 +0200 |
commit | 8689900a386fb1c767350e70dc02774fc9cc39c5 (patch) | |
tree | 40f1cf8aff02c3bb43aa21e2a53cdd4f539d8173 /module | |
parent | new config options, webinterface test (diff) | |
download | pyload-8689900a386fb1c767350e70dc02774fc9cc39c5.tar.xz |
webinterface cache control, curl fix
Diffstat (limited to 'module')
-rwxr-xr-x | module/network/Request.py | 3 | ||||
-rw-r--r-- | module/web/WebServer.py | 24 | ||||
-rw-r--r-- | module/web/bottle.py | 5 | ||||
-rw-r--r-- | module/web/static/favicon.ico (renamed from module/web/static/pyload.ico) | bin | 7206 -> 7206 bytes |
4 files changed, 25 insertions, 7 deletions
diff --git a/module/network/Request.py b/module/network/Request.py index 0427bbe25..11c8fae89 100755 --- a/module/network/Request.py +++ b/module/network/Request.py @@ -164,8 +164,7 @@ class Request: def add_auth(self, user, pw): if self.curl: - self.pycurl.setopt(pycurl.USERNAME, user) - self.pycurl.setopt(pycurl.PASSWORD, pw) + self.pycurl.setopt(pycurl.USERPWD, user + ":" + pw) self.pycurl.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_ANY) else: self.downloader.addheaders.append(['Authorization', 'Basic ' + base64.encodestring(user + ':' + pw)[:-1]]) diff --git a/module/web/WebServer.py b/module/web/WebServer.py index ad0d03512..cd5c57a70 100644 --- a/module/web/WebServer.py +++ b/module/web/WebServer.py @@ -21,6 +21,7 @@ import threading import bottle +import time from bottle import abort from bottle import db from bottle import debug @@ -34,10 +35,10 @@ from bottle import template from bottle import validate -debug(True) core = None PATH = "./module/web/" +TIME = time.strftime("%a, %d %b %Y 00:00:00 +0000", time.localtime()) #set time to current day @route('/', method= 'POST') def home(): @@ -52,26 +53,41 @@ def login(): @route('/favicon.ico') def favicon(): - send_file('pyload.ico', PATH + 'static/') + redirect('/static/favicon.ico') @route('static/:section/:filename') def static_folder(section, filename): + + if request.HEADER("HTTP_IF_MODIFIED_SINCE") == TIME: abort(304, "Not Modified") + + response.header['Last-Modified'] = TIME send_file(filename, root=(PATH + 'static/' + section)) @route('/static/:filename') def static_file(filename): + + if request.HEADER("HTTP_IF_MODIFIED_SINCE") == TIME: abort(304, "Not Modified") + + response.header['Last-Modified'] = TIME send_file(filename, root=(PATH + 'static/')) class WebServer(threading.Thread): def __init__(self, pycore): threading.Thread.__init__(self) - global core + global core, TIME core = pycore self.core = pycore self.setDaemon(True) + if pycore.config['general']['debug_mode']: + bottle.debug(True) + TIME = time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.localtime()) + else: + bottle.debug(False) + bottle.TEMPLATE_PATH.append('./module/web/templates/%s.tpl') def run(self): - run(host='localhost', port=int(self.core.config['webinterface']['port']))
\ No newline at end of file + self.core.logger.info("Starting Webinterface on port %s" % self.core.config['webinterface']['port']) + run(host='localhost', port=int(self.core.config['webinterface']['port']), quiet=True) diff --git a/module/web/bottle.py b/module/web/bottle.py index 8335f112b..8d4570bb7 100644 --- a/module/web/bottle.py +++ b/module/web/bottle.py @@ -342,6 +342,9 @@ class Request(threading.local): self._COOKIES[cookie.key] = cookie.value return self._COOKIES + def HEADER(self, header): + """Returns HTTP header""" + return self._environ.get(header, '') class Response(threading.local): """ Represents a single response using thread-local namespace. """ @@ -548,7 +551,7 @@ def run(app=None, server=WSGIRefServer, host='127.0.0.1', port=8080, **kargs): print 'Listening on http://%s:%d/' % (server.host, server.port) print 'Use Ctrl-C to quit.' print - +pri try: server.run(app) except KeyboardInterrupt: diff --git a/module/web/static/pyload.ico b/module/web/static/favicon.ico Binary files differindex 58b1f4b89..58b1f4b89 100644 --- a/module/web/static/pyload.ico +++ b/module/web/static/favicon.ico |