Created
June 28, 2018 20:30
-
-
Save sergeyhush/b3ccede87ec7464c044018154fc6d9b3 to your computer and use it in GitHub Desktop.
Fake API server driver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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