summaryrefslogtreecommitdiffstats
path: root/module/web
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-08-17 20:08:20 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-08-17 20:08:20 +0200
commit8689900a386fb1c767350e70dc02774fc9cc39c5 (patch)
tree40f1cf8aff02c3bb43aa21e2a53cdd4f539d8173 /module/web
parentnew config options, webinterface test (diff)
downloadpyload-8689900a386fb1c767350e70dc02774fc9cc39c5.tar.xz
webinterface cache control, curl fix
Diffstat (limited to 'module/web')
-rw-r--r--module/web/WebServer.py24
-rw-r--r--module/web/bottle.py5
-rw-r--r--module/web/static/favicon.ico (renamed from module/web/static/pyload.ico)bin7206 -> 7206 bytes
3 files changed, 24 insertions, 5 deletions
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
index 58b1f4b89..58b1f4b89 100644
--- a/module/web/static/pyload.ico
+++ b/module/web/static/favicon.ico
Binary files differ