2 days is enough to see the historic area and the top highlights of Hangzhou, mainly the West Lake area & Lingyin Temple, plus other urban attractions like the Qinghefang Old Street, Former Residence of Hu Xueyan, and perhaps the newly built downtown Qianjiang CBD
If you want to include the attractions in the surrounding areas of Hangzhou, like the Xixi Wetlands, Yunxi Zhujing bamboo forest, Longjing Tea fields, and Wuzhen water village, then you should plan 3-5 days
It's also not unheard of to do a 1 day trip from Shanghai. It takes less than 1 hour to travel to Hangzhou from Shanghai via the high speed rail. You can take the morning train here, see just the West Lake area (which is really what Hangzhou is known for anyway), then take the night train back to Shanghai