Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fake API server driver
#!/bin/sh
PORT=8002
SERVER_NAME="127.0.0.1:${PORT}"
trap cleanup EXIT
cleanup(){
kill $(lsof -ti tcp:$PORT)
}
[ ! -d venv ] && virtualenv vevn
FLASK_DEBUG=1 FLASK_SERVER_PORT=$PORT venv/bin/python fake_api.py &
sleep 1
TOKEN=$(curl -X POST -H "Content-Type: application/json" -d '{"email":"sergey@cumulusnetworks.com","password":"CumulusLinux!"}' http://${SERVER_NAME}/api-token-auth/ | jq -r ".Token")
echo "Auth token $TOKEN"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment