summaryrefslogtreecommitdiff
path: root/app.py
diff options
context:
space:
mode:
Diffstat (limited to 'app.py')
-rwxr-xr-xapp.py16
1 files changed, 3 insertions, 13 deletions
diff --git a/app.py b/app.py
index 1da175f..9120ea4 100755
--- a/app.py
+++ b/app.py
@@ -4,6 +4,7 @@ import os, mimetypes, json, cgi, recode, time, urllib, events, threading
from config import config
from directory import Directory, File
+from session import Session
class Application(object):
# Application handlers
@@ -58,28 +59,17 @@ class Application(object):
encoder = args.getvalue('encoder') if 'encoder' in args else None
f = File(path)
- t = threading.Thread(target = f.recode, args = (decoder, encoder))
+ t = threading.Thread(target = f.recode, args = (decoder, encoder, environ['sessionid']))
t.start()
start_response('200 OK', [('Content-Type', 'text/plain')])
return []
- def json_is_cached(self, environ, start_response, path):
- args = cgi.FieldStorage(environ = environ)
- path = args.getvalue('path') if 'path' in args else None
-
- cache_file = os.path.join(config.get('cache_dir'), path)
- cache_file = os.path.splitext(cache_file)[0] + '.mp3'
-
- start_response('200 OK', [('Content-Type', 'text/plain')])
- return json.dumps(os.path.exists(cache_file))
-
handlers = {
'files': files,
'static': static,
'list': json_list,
'cache': json_cache,
- 'is_cached': json_is_cached,
'events': events.EventSubscriber,
}
@@ -94,7 +84,7 @@ class Application(object):
path = ['static', 'index.html']
if module in self.handlers:
- return self.handlers[module](self, environ, start_response, path)
+ return Session(self.handlers[module])(self, environ, start_response, path)
start_response('404 Not Found', [('Content-Type', 'text/plain')])
return [str(path)]