FLATIRON — A student at a coding school is facing felony charges after he told his peers that he was planning to return to school with a shotgun to shoot students and staff, according to the NYPD.

Peter Rao, 26, of Hackensack, New Jersey, was arrested on July 2, several days after he threatened to go on a rampage at the SoHo location of App Academy, an intensive learn-to-code education center with branches in San Francisco and New York, according to a criminal complaint.

It was not immediately clear what caused Rao to be upset with the students and staff of the school, but he made it clear that he wished to harm them, according to a criminal complaint.

“I’m going to come back to school with a shotgun and shoot all the students and then the staff,” Rao told multiple students on June 27, according to a criminal complaint.

Rao had previously made other students uncomfortable with his behavior, so when the school’s director found out he had made the threats, he was immediately kicked out, according to police.

In response, Rao told the director, “this is the kind of thing that makes me want to do something like that,” police said.

Police from the 13th Precinct arrested him in Flatiron over the weekend, according to the complaint.

Prosecutors charged Rao with making a terrorist threat, a felony, according to a spokeswoman for the Manhattan District Attorney’s office. A judge ordered him held on $10,000 bail, which he posted the next day, records show.

Rao was due back in court on Thursday, according to court records.

A lawyer for Rao and representatives of App Academy did not immediately respond to requests for comment.