Show More
@@ -53,12 +53,17 b' def staticfile(directory, fname, req):' | |||||
53 |
|
53 | |||
54 | """ |
|
54 | """ | |
55 | parts = fname.split('/') |
|
55 | parts = fname.split('/') | |
56 | path = directory |
|
|||
57 | for part in parts: |
|
56 | for part in parts: | |
58 | if (part in ('', os.curdir, os.pardir) or |
|
57 | if (part in ('', os.curdir, os.pardir) or | |
59 | os.sep in part or os.altsep is not None and os.altsep in part): |
|
58 | os.sep in part or os.altsep is not None and os.altsep in part): | |
60 | return "" |
|
59 | return "" | |
61 |
|
|
60 | fpath = os.path.join(*parts) | |
|
61 | if isinstance(directory, str): | |||
|
62 | directory = [directory] | |||
|
63 | for d in directory: | |||
|
64 | path = os.path.join(d, fpath) | |||
|
65 | if os.path.exists(path): | |||
|
66 | break | |||
62 | try: |
|
67 | try: | |
63 | os.stat(path) |
|
68 | os.stat(path) | |
64 | ct = mimetypes.guess_type(path)[0] or "text/plain" |
|
69 | ct = mimetypes.guess_type(path)[0] or "text/plain" |
@@ -583,10 +583,7 b' def static(web, req, tmpl):' | |||||
583 | tp = web.templatepath |
|
583 | tp = web.templatepath | |
584 | if isinstance(tp, str): |
|
584 | if isinstance(tp, str): | |
585 | tp = [tp] |
|
585 | tp = [tp] | |
586 | for path in tp: |
|
586 | static = [os.path.join(p, 'static') for p in tp] | |
587 | static = os.path.join(path, 'static') |
|
|||
588 | if os.path.isdir(static): |
|
|||
589 | break |
|
|||
590 | return [staticfile(static, fname, req)] |
|
587 | return [staticfile(static, fname, req)] | |
591 |
|
588 | |||
592 | def graph(web, req, tmpl): |
|
589 | def graph(web, req, tmpl): |
General Comments 0
You need to be logged in to leave comments.
Login now