ST. LOUIS — The St. Louis Cardinals were a .500 team at the All-Star break.

They spent the trade deadline doing absolutely nothing.

But here they were Sunday, on the final day of the season, celebrating the National League Central Division championship with a 9-0 laugher over the Chicago Cubs.

A lot has happened in St. Louis since the Cardinals were last in the playoffs.

They had an NFL team, before it packed up and moved to Los Angeles. Their hockey team had never sniffed a Stanley Cup championship.

But now, after a four-year drought, the Cardinals are back in the playoffs once again.

“We believed in these guys from the start,’’ Cardinals president John Mozeliak said over the weekend. “It took awhile, but they persevered, and played just like we thought all along.’’

JOE MADDON: Skipper has no regrets about tenure with Cubs

MLB AWARDS: Handing out the hardware

The Cardinals put together one of the greatest finishing kicks in franchise history, going 47-26 after July 13, even with a four-game losing streak in the final week that ended with Sunday’s victory.

And it was only fitting that Cy Young contender Jack Flaherty was on the mound for the coronation.

Flaherty has done his best Bob Gibson impression since the All-Star break, yielding a 0.91 ERA, the third-lowest in major league history behind only Greg Maddux and Jake Arrieta.

Flaherty suffocated the Cubs’ offense once again, just like has throughout his young career. The Cubs produced just two singles off Flaherty in seven innings. He has limited the Cubs to a .156 batting average in his career.

“He’s the hottest pitcher on the planet,’’ Cardinals veteran starter Adam Wainwright said. “We’re not here without him, that’s for sure.’’

The Cardinals, whose playoff drought was the longest in 20 years for this rabid baseball city, underwent a complete transformation with their core of talent still intact.

They became the first team in Major League Baseball history to go from last to first in fielding, committing just 66 errors compared to 133 errors a year ago. It’s the first time they led baseball in fielding since 1985.

They led the league in stolen bases for the first time since 1992, and their 79.9 stolen-base percentage is the highest since at least 1951 in franchise history. They had 19 players steal at least one base, the most in baseball, and just two shy of the franchise record set in 1906.

And they beat you with power, too, and with their 210 homers and 115 stolen bases, are just the third team in franchise history to have at least 200 homers and 100 stolen bases in the same season.

They are a complete team, and a dangerous one, that could wreak havoc in the National League playoffs.

Sure, they wish they didn’t have to pitch Flaherty on Sunday, saving him for Game 1 of the Division Series, but they’ll still have him available on regular rest in Game 2 in Atlanta, and potentially a deciding Game 5.

They are expected to pitch Miles Mikolas in Game 1, Flaherty in Game 2, Wainwright in Game 3 and likely Mikolas on short rest in Game 4.

It may be the most compelling first-round matchup, with each team considered virtually equal, and no clear-cut favorite.

“We like our team, and we like it a lot,’’ Cardinals catcher Yadier Molina said. “That hasn’t changed all year.

“We think we’re good. Now, we’re about to see how good we really are.’’