Question: who was the president when the national anthem was written
Answer: On September 3 , 1814 , following the Burning of Washington and the Raid on Alexandria , Francis Scott Key and John Stuart Skinner set sail from Baltimore aboard the ship HMS Minden , flying a flag of truce on a mission approved by President James Madison .