def get_context(): context = {"working_directory": ".", "detach_process": False} if conf("server.daemonize"): log_file = open(conf("server.daemon_log"), "w+") context.update(detach_process=True, stdout=log_file, stderr=log_file) else: context.update(files_preserve=[sys.stdout, sys.stderr], stdout=sys.stdout, stderr=sys.stderr) return daemon.DaemonContext(**context)
def get_context(): context = {'working_directory': '.', 'detach_process': False} if conf('server.daemonize'): log_file = open(conf('server.daemon_log'), 'w+') context.update(detach_process=True, stdout=log_file, stderr=log_file) else: context.update(files_preserve=[sys.stdout, sys.stderr], stdout=sys.stdout, stderr=sys.stderr) return daemon.DaemonContext(**context)
def get(self, path): if path.strip('/') == '': path = 'index.html' root = conf('server.static_path') path = os.path.join(root, path) if not path.startswith(root): return Response(status=400, body='400 Bad Request') else: return Response(status=200, body=file(path, 'rb').read())