def browser(path=None): uploads_dir = app.config['UPLOADS_DIRECTORY'] path_join = op.join(uploads_dir, path) # if path is toplevel output dir, check for result tarball # if tarball exists, trigger output download if path.endswith('-output'): result_targz = '{0}.tar.gz'.format(path) result_path = op.join(uploads_dir, result_targz) if op.exists(result_path): return redirect(url_for('download', path=result_targz)) # if result file not ready yet, let user browse the run directory if op.isdir(path_join): folder = Folder(uploads_dir, path) folder.read() return render_template('folder.html', folder=folder) else: my_file = File(uploads_dir, path) context = my_file.apply_action(View) folder = Folder(uploads_dir, my_file.get_path()) if context == None: return render_template('file_unreadable.html', folder=folder) return render_template('file_view.html', text=context['text'], file=my_file, folder=folder)
def index(path=''): path_join = os.path.join(app.config['FILES_ROOT'], path) if os.path.isdir(path_join): folder = Folder(app.config['FILES_ROOT'], path) folder.read() return render_template('folder.html', folder=folder) else: my_file = File(app.config['FILES_ROOT'], path) context = my_file.apply_action(View) folder = Folder(app.config['FILES_ROOT'], my_file.get_path()) if context is None: return render_template('file_unreadable.html', folder=folder) return render_template('file_view.html', text=context['text'], file=my_file, folder=folder)
def view_content(path=''): print "hello" app.config.update( DEBUG=True, FILES_ROOT=os.path.dirname(os.path.abspath(__file__)), ) path_join = os.path.join(app.config['FILES_ROOT'], path) my_file = File(app.config['FILES_ROOT'], path) context = my_file.apply_action(View) folder = Folder(app.config['FILES_ROOT'], my_file.get_path()) if context == None: return render_template('file_unreadable.html', folder=folder) return render_template('file_view.html', text=context['text'], file=my_file, folder=folder)