Commit d4eeb122 authored by Per Cederqvist's avatar Per Cederqvist

Extract the BASE config setting to mp3wavcfg.py.

parent 924799a6
BASE = '/home/ceder/tmp/2014/sample'
......@@ -3,7 +3,7 @@ import stat
import io
import urllib.parse
BASE = '/home/ceder/tmp/2014/sample'
import mp3wavcfg
def quote(s):
return urllib.parse.quote(s)
......@@ -28,7 +28,7 @@ def application(environ, start_response):
filename = os.path.basename(path)
realfile = os.path.join(BASE, subdir, filename)
realfile = os.path.join(mp3wavcfg.BASE, subdir, filename)
try:
status = os.stat(realfile)
......@@ -60,8 +60,8 @@ def handle_directory(environ, start_response, rel_path):
mp3s = {}
dirs = set()
for fn in os.listdir(os.path.join(BASE, rel_path)):
realfile = os.path.join(BASE, rel_path, fn)
for fn in os.listdir(os.path.join(mp3wavcfg.BASE, rel_path)):
realfile = os.path.join(mp3wavcfg.BASE, rel_path, fn)
try:
status = os.stat(realfile)
except os.error:
......@@ -124,7 +124,7 @@ def handle_file(environ, start_response, rel_path):
start_response("403 Forbidden", [])
return []
file = open(os.path.join(BASE, rel_path), "r")
file = open(os.path.join(mp3wavcfg.BASE, rel_path), "r")
start_response("200 OK", [("Content-Type", content_type)])
if 'wsgi.file_wrapper' in environ:
return environ['wsgi.file_wrapper'](file, 1024 * 1024)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment