Yes flies do have brains.
The brains that flies have are not as important as human brains and actually a fly can live for a few days without it's brain.
However the fly does need a brain for the processing of information and to allow movement of it's body and to be able to see.
A flies brain is about 100,000 neurons and like the fly the brain a fly has is very tiny.
Flies also have a pretty short lifespan and the average fly lives about 28 days before dying of natural causes.
Although most flies are killed off by us humans to get rid of them in the house and around us.
Flies although annoying do play a very important role in the earth as they eat away at decaying matter.