The city spent years sweeping porn and peep shows from Times Square — and in just a matter of months, the de Blasio administration brought back the sleaze, The Post has learned.

The XXX-rated action returned to the Crossroads of the World via tablet-equipped street kiosks that horny hobos and even some curious school kids have used to get their kicks.

The city announced an innovative program in January designed to offer free high-speed Internet access at former telephone booths throughout the city.

But the plan badly backfired when scores of homeless men — and some schoolchildren — soon realized they could surf porn sites all day on the city’s dime using the communal Android-run tablets and gratis Wi-Fi.

“I used to come here in the ’70s, and I remember thinking Times Square was as skeezy as you could get, but I was wrong,” said former New Yorker Richard Herzberg, 61, who now lives in Dallas, Texas.

“This is as skeezy as Times Square could get. I mean, in the old days there was plenty of porn, but you could only see it behind closed doors. So at least there was that level of modesty.”

The kiosks, particularly those along Eighth Avenue in the West 30s, became havens for denizens of the Port Authority Bus Terminal and its surrounding streets, as well as patients at local methadone clinics, nearly as soon as they were converted for Web use, according to several NYPD officials.

The like-to-watch throngs became such a plague that the company that created the kiosks for the city had to add an additional filter to thwart them.

The company, LinkNYC, “use[s] a highly regarded content monitoring system used by thousands of public schools and libraries across the country, and we recently implemented an additional filter for image searches,’’ said Ruth Fasoldt, a community-affairs manager for the firm.

The move did not sit well with the hardcore-loving street people.

“I was watching porn on one of them things on, like, Saturday,” said a homeless man who identified himself as Hakeem, 44.

“This is as skeezy as Times Square could get. I mean, in the old days there was plenty of porn, but you could only see it behind closed doors. So at least there was that level of modesty.” - Richard Herzberg

“Then on, like, Monday or Tuesday, all of a sudden I couldn’t,” he added.

“Once word got around, it stopped. It sucks, man. It was great.”

But he lamented that “there were kids who were skipping school and just coming over here to watch porn. The cops had to come and break them up.”

Joseph, 28, another homeless man, recalled his sadness upon discovering the free porn he was enjoying had suddenly stopped streaming.

“I was kind of pissed,” he said.

There are now 180 such kiosks in Manhattan and The Bronx, with up to 7,500 in the pipeline.

Additional reporting by Jamie Schram