Hello Daya Mayi,
Make sure you have your doctor’s clearance for exercise; when you do, mention what you would like to do and ask for advice on what is approved for your situation.
About the weight gain concern, your body is using calories to heal; so, eat healthy and let the magic healing do its thing. This too shall pass and you will be back in the game in no time.
I would contact your doctor to see what he or she thinks is best. They will almost certainly be on the conservative side. Most upper body training should be relatively safe. Most gyms don’t have it, but a Nu-step machine can allow you to exercise the non-affected leg if you are careful and creative with the setup.
Above all, I would watch what you are eating. That is the easiest way to make sure you won’t gain weight during periods of inactivity.
Daya, I agree with the others about getting permission from your doctor before getting back to exercise. If your doctor agrees I would recommend getting in the pool with a buoy so you won’t need your legs. If you are not currently swimming you may need to consult with a swim coach, but this would allow you to get some great cardio without using your legs. I hope you heal quickly.