Exercise whilst pregnant

I haven’t really been active - I occasionally walk, like once a month. Been to the gym a few times. But can I start exercising when pregnant? Long walks, cardio (treadmill). Is it safe?