Yes, flour can certainly replace cornstarch to thicken a sauce, but you need to account for a few differences in preparation. Since flour has about half the thickening power of cornstarch, you generally need to use twice as much flour by volume.
To prevent lumps, it is best to prepare a roux or a slurry:
1. Roux method: Melt equal parts butter and flour in a pan over medium heat, cooking for a minute or two to remove the raw flour taste, then gradually whisk in your warm liquid.
2. Slurry method: Whisk the flour thoroughly with a small amount of cold water until completely smooth before stirring it into your simmering sauce.
Keep in mind that flour will give the sauce a slightly opaque or matte finish rather than the glossy sheen you typically get with cornstarch.