Handle get and post requests.