I’ve been doing this recently, and this is how I did it。
def serve
file_path = File.expand_path(
params[:path]+"."+params[:format],
File.join(File.dirname(__FILE__), "../../public")
)
if File.file?(file_path)
send_file file_path, type: "text/html", disposition: "inline"
else
render plain: "404 Not Found", status: 404
end
end