Peel the zucchini, remove the soft center. Cut the hard vegetables into larger pieces and then grate finely (use a potato grater!).
Peel the onion and grate it as well. Fry the bacon or ham briefly in a hot pan, fold into the grated mixture. Mix in the grated cheese, flour, eggs and oil, season with salt and pepper.
Put the mixture into a shallow ovenproof dish and bake in a preheated oven at 200 degrees for about 1 hour. Let the gratin cool down a bit so that it becomes firmer and only then serve it. But tastes quite good cold too!