During which war was the Star Spangled written?

During which war was the Star Spangled written?