I had that problem a few months ago when I brought produce home from the farmer's market..
What I did was take a small clear bowl, put some red wine in it and cover it with plastic wrap. Take a toothpick and poke some holes in it. They will go in and not be able to get back out. In a week or so the amount of flies in your house will be down. Be sure to really clean your kitchen too.. drains, counters, dishwasher, fridge, and stove top. They get in EVERYWHERE. They're so annoying :(.
If you don't drink wine at all I've heard you can try apple vinegar. I haven't tried it though so I can't tell you if it does or doesn't work.