Skip to content

Instantly share code, notes, and snippets.

@mountain
Created March 12, 2020 04:06
Show Gist options
  • Save mountain/6dd910350c8ddb2411d2ebdfc5fee8d9 to your computer and use it in GitHub Desktop.
Save mountain/6dd910350c8ddb2411d2ebdfc5fee8d9 to your computer and use it in GitHub Desktop.
DIRECTION=$1
SOURCE=$2
if test -f $HOME/.xiaoyi ; then
. $HOME/.xiaoyi
else
echo "Please input ip of your node: "
read NODEIP
echo "NODEIP=$NODEIP" > $HOME/.xiaoyi
fi
BODY='{"source": ["'$SOURCE'"], "trans_type": "'$DIRECTION'", "replaced": true, "media": "text", "request_id": "demo" }'
export PYTHONIOENCODING=utf8
curl -s -X POST http://$NODEIP/translator -H 'Content-Type: application/json' -d "$BODY" | python -c "import sys, json; print json.load(sys.stdin)['target'][0]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment