public Response getResponse (Request req, Route route)
	{
		if (!req.path.startsWith (route.pathPrefix))
			throw new IllegalArgumentException ("bad request path for view");
		
		String subpath = req.path.substring (route.pathPrefix.length ());
		if (subpath.startsWith ("/"))
			subpath = subpath.substring (1);
		
		String mimeType = "application/octet-stream";
		int dotPosition = subpath.lastIndexOf ('.');
		if (dotPosition >= 0)
		{
			String ext = subpath.substring (dotPosition + 1);
			String newMimeType = (String) MIME_TYPES.get (ext);
			if (newMimeType != null)
				mimeType = newMimeType;
		}
		
		String path = directory + subpath;
		InputStream is = getClass ().getResourceAsStream (path);
		System.out.println (is);
		if (is == null)
			return Response.createErrorResponse (404);
		
		Response res = new Response (null, mimeType);
		
		try {
			int k;
			while ((k = is.read ()) != -1)
				res.write (k);
		} catch (IOException e) {
			e.printStackTrace ();
			return Response.createErrorResponse (500);
		} finally {
			try {
				is.close ();
				res.close ();
			} catch (IOException e) {}
		}
		
		return res;
	}