if trace is not None: details['trace'] = trace.split('\n') return flask.jsonify({'error': details}), status_code else: return flask.render_template('error.html', title = error_type, message = message, description = description, trace = trace, ), status_code # Register this handler for all error codes # Necessary for flask<=0.10.1 for code in HTTP_STATUS_CODES: if code not in [301]: app.register_error_handler(code, handle_error) ### File serving @app.route('/files/<path:path>', methods=['GET']) @autodoc('util') def serve_file(path): """ Return a file in the jobs directory If you install the nginx.site file, nginx will serve files instead and this path will never be used """ jobs_dir = config_value('jobs_dir') return flask.send_from_directory(jobs_dir, path)
return flask.jsonify({'error': details}), status_code else: return flask.render_template( 'error.html', title=error_type, message=message, description=description, trace=trace, ), status_code # Register this handler for all error codes # Necessary for flask<=0.10.1 for code in HTTP_STATUS_CODES: if code not in [301]: app.register_error_handler(code, handle_error) ### File serving @app.route('/files/<path:path>', methods=['GET']) @autodoc('util') def serve_file(path): """ Return a file in the jobs directory If you install the nginx.site file, nginx will serve files instead and this path will never be used """ jobs_dir = config_value('jobs_dir') return flask.send_from_directory(jobs_dir, path)