import requests res = requests.get('http://127.0.0.1:5001/api/data') res.json() %%script bash lsof -i :5001 | awk '/Python/ {print $2}' | xargs kill -9