Flies, and all insects for that matter, don’t have endocannabinoid systems (ECS). This system is necessary for properly binding THC, the active chemical in cannabis that makes you feel high. In us, and similar mammals, THC binds to CB1 receptors in our brain and that’s why we feel high.
Insects don’t have these receptors, so they can’t feel high from cannabis. Instead they consume these chemicals, like THC, and excrete them like anything else after a while.