As President Trump nears his  first anniversary in office, he  faces an unforgiving political  landscape. Every word he says and every action he takes will either help him keep a Republican Congress or hand control to Democrats.

And if Dems get the gavel, impeachment could be the result.

This is the binary world Trump inhabits, and seen through that lens, the uproar over the president’s disparaging remarks about Haiti and other poor countries helps Dems in their goal of hobbling if not ending his presidency.

Despite his denial that he used the words “s---hole countries,” most of the media instantly branded him a racist. After a few days of saturation coverage, polls will show a disapproving public and the ritual beatdown will be complete.

Then we’ll be on to the next ­crisis because this is life with Trump in the White House. He and we are always on the razor’s edge because that’s who he is.

That’s been the pattern for a year, and the president has managed to keep his head above water. But past performance is not a guarantee of future results — ­especially in an election year when passions against him are already overheating.

Consider that a potty-mouth president is hardly a new phenomenon. John F. Kennedy, Lyndon B. Johnson and Richard Nixon said far worse things, not to mention the words Bill Clinton must have used during his Oval Office trysts. But Trump is in a unique position.

While a biased media hyperventilating is no virtue, Trump’s great flaw is that he keeps giving them ammunition. One minute he’s riding high, the next he’s running for his life.

Not because of what he says or does, but because of the reaction to it. With over half the country needing no more reason than his election to demand his removal, and with many Democrats promising impeachment if they gain power, every mistake is potentially fatal.

Each one gives the anti-Trump media license to go from zero to DEFCON 1, signifying an extreme national emergency.

Yet while a biased media hyperventilating is no virtue, Trump’s great flaw is that he keeps giving them ammunition. One minute he’s riding high, the next he’s running for his life.

The “s---hole” storm is a perfect case in point.

Still basking in the afterglow of getting tax reform passed, Trump confidently convened a bipartisan group of congressional members for a televised meeting Wednesday on the “Dreamers” and related ­immigration issues.

The president presided in such CEO fashion that even CNN — yes, CNN — declared the meeting remarkable and Trump’s leadership commendable.

The next day, the president boasted about the compliments — and then acted as if he were ­beloved from sea to shining sea. At a follow-up meeting, he unleashed the furies with his derogatory ­remarks.

Did he forget that Democrats are out for his blood? Didn’t he learn anything from the torrent of White House leaks that bedeviled his early months?

For my money, “s---hole countries” is not by itself a racist remark. It’s certainly crude and shouldn’t be said by a president, but those countries are a total mess. Central America is the murder capital of the world, and Haitians have been fleeing their country for years because they’ve given up hope it can be fixed.

And the context matters: Trump and Congress were bargaining over the fact that Haitians, El Salvadorans and people from African countries who were admitted years, and in some cases decades ago, after emergencies were allowed to stay indefinitely.

You don’t have to be a racist to conclude that isn’t sound immigration policy, and that America should pick the immigrants who can contribute to its prosperity and security. Indeed, there is a growing bipartisan consensus on that point, which is why chain ­migration and the visa lottery were on the table.

That was then. Now Trump has made it more difficult, and maybe impossible, to move the needle in that direction. Getting funding for the wall will be doubly difficult.

Even a “Dreamers” deal may be a bridge too far, with the open-borders movement gleefully using the uproar to demand even more “love” than the president was prepared to offer. That will force moderate Dems to play hardball and Republicans will fold, as is their wont when Trump embarrasses them.

This, then, is shaping up as ­another moment where style beats substance, and identity politics ­determines policy.

As I have said, Trump has an impressive list of achievements, and his presidency marks an important course correction for America. The expanding economy, as reflected in job and wage growth and stock-market exuberance, remains Exhibit A on his promises-kept list.

But the job isn’t done. To have a successful presidency, Trump needs to finish what he started and that means keeping a Republican Congress for four years. For that to happen, he must start behaving as if his future depends on every word he says every day.

Because it does.

And if he needs to blow off steam without blowing the lid off his presidency, he ought to remember the sage advice often attributed to President Harry ­Truman.

If you want a friend in Washington, get a dog.

To read more Michael Goodwin on the New York Post click here.