During which war was the Star Spangled written?

History Trivia: During which war was the Star Spangled written?