function handleRequest(request, response){
	response.setHeader("Access-Control-Allow-Origin", "http://localhost:9009")

	const url = URL.parse(request.url, true);

	let dir = decodeURIComponent(url.pathname).replace(/\/$/, '');
	if (dir === '') {
		dir = '/';
	}

	const depth = url.query.depth || 1;

	if (url.query.processes) {
		handleProcessRequest(request, response);
		return;
	} else if (url.query.thumbnail) {
		handleThumbnailRequest(request, response, url.query.thumbnail);
		return;
	} else if (url.query.git) {
		handleGitRequest(request, response, url.query.git);
		return;
	}

	sendDirTree(dir, depth, response);
}
//We need a function which handles requests and send response
We need a function which handles requests and send response
We need a function which handles requests and send response
function handleRequest(request, response){
	response.setHeader("Access-Control-Allow-Origin", "http://localhost:9009")
	const url = URL.parse(request.url, true);
	let dir = decodeURIComponent(url.pathname).replace(/\/$/, '');
	if (dir === '') {
		dir = '/';
	}
	const depth = url.query.depth || 1;
	if (url.query.processes) {
		handleProcessRequest(request, response);
		return;
	} else if (url.query.thumbnail) {
		handleThumbnailRequest(request, response, url.query.thumbnail);
		return;
	} else if (url.query.git) {
		handleGitRequest(request, response, url.query.git);
		return;
	}
	sendDirTree(dir, depth, response);
}
function handleRequest ( request , response ) { response . setHeader ( "Access-Control-Allow-Origin" , "http://localhost:9009" ) const url = URL . parse ( request . url , true ) ; let dir = decodeURIComponent ( url . pathname ) . replace ( / \/$ / , '' ) ; if ( dir === '' ) { dir = '/' ; } const depth = url . query . depth || 1 ; if ( url . query . processes ) { handleProcessRequest ( request , response ) ; return ; } else if ( url . query . thumbnail ) { handleThumbnailRequest ( request , response , url . query . thumbnail ) ; return ; } else if ( url . query . git ) { handleGitRequest ( request , response , url . query . git ) ; return ; } sendDirTree ( dir , depth , response ) ; }
We need a function which handles requests and send response
We need a function which handles requests and send response