There is no generally agreed definition of what constitutes art,...":
That isn't to say it can't be art. Only that those with an interest in calling it art usually aren't the appropriate authorities.
[1]: https://idlewords.com/2005/04/dabblers_and_blowhards.htm
If programming itself isn't art, the cognition of its product surely is. Art in a gallery asks to be observed again, studied again, brought to the context of each discovered age, again.
Then there is "code as an artform". Think code golf, or other such challenges that encourage incredibly creative solutions.
Then my personal favorite is simply "beautiful code". Sometimes an algorithm or a function will just be elegant in its construction or simplicity. Sometimes you have a real hairy problem that seems very complex at first, but the solution ends up as a small, clean function with no frills, no bugs. It's about beautiful solutions more than the text of the code.
Code can be art, but it usually isn't. The first two categories are something done intentionally as a form of expression, but the last is more akin to a sunset or a rainbow. Sometimes beauty appears when we don't intend or expect it. But I think that still qualifies as art.