Skip to content

Instantly share code, notes, and snippets.

@sergeyhush
Created June 28, 2018 20:30
Show Gist options
  • Save sergeyhush/b3ccede87ec7464c044018154fc6d9b3 to your computer and use it in GitHub Desktop.
Save sergeyhush/b3ccede87ec7464c044018154fc6d9b3 to your computer and use it in GitHub Desktop.
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":"[email protected]","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