respond to either html or json requests