def test_url_unescape(): # decodes a url string to a plain string # these tests decode paths with spaces path = url_unescape('/this%20is%20a%20test/for%20spaces/') nt.assert_equal(path, '/this is a test/for spaces/') path = url_unescape('notebook%20with%20space.ipynb') nt.assert_equal(path, 'notebook with space.ipynb') path = url_unescape('/path%20with%20a/notebook%20and%20space.ipynb') nt.assert_equal(path, '/path with a/notebook and space.ipynb') path = url_unescape( '/%20%21%40%24%23%25%5E%26%2A%20/%20test%20%25%5E%20notebook%20%40%23%24%20name.ipynb') nt.assert_equal(path, '/ !@$#%^&* / test %^ notebook @#$ name.ipynb')
def test_url_unescape(): # decodes a url string to a plain string # these tests decode paths with spaces path = url_unescape('/this%20is%20a%20test/for%20spaces/') nt.assert_equal(path, '/this is a test/for spaces/') path = url_unescape('notebook%20with%20space.ipynb') nt.assert_equal(path, 'notebook with space.ipynb') path = url_unescape('/path%20with%20a/notebook%20and%20space.ipynb') nt.assert_equal(path, '/path with a/notebook and space.ipynb') path = url_unescape( '/%20%21%40%24%23%25%5E%26%2A%20/%20test%20%25%5E%20notebook%20%40%23%24%20name.ipynb' ) nt.assert_equal(path, '/ !@$#%^&* / test %^ notebook @#$ name.ipynb')
def post(self, path): """ Write uploaded files to disk. :param path: """ files = self.request.files if not len(files): raise web.HTTPError(400, "missing files to upload") root_path = os.path.join(self.work_dir, path.strip("/")) written_paths = [] for filename, metas in files.items(): path = url_unescape(os.path.join(root_path, filename)) with open(path, "wb") as fh: fh.write(metas[0].body) written_paths.append(path) self.finish({"files": written_paths, "path": url_unescape(root_path)})