Skip to content

Commit

Permalink
Virtualenv maybe
Browse files Browse the repository at this point in the history
  • Loading branch information
pikesley committed Nov 19, 2017
1 parent 374b9da commit 88508f5
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ venv/
__pycache__/
*.swp
coverage

bin/
*python2.7*
pip-selfcheck.json
.Python
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ phat:
python webserver.py &
sleep 2
./towers phat

fake-phat:
python dummywebserver.py &
sleep 2
./towers phat

kill:
kill `ps ax | grep webser | tr -s ' ' ' ' | cut -d ' ' -f 1`
34 changes: 34 additions & 0 deletions dummywebserver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from flask import Flask, request
import json

app = Flask(__name__)


@app.route("/lights", methods=['POST'])
def lights():
data = json.loads(request.data)['data']
s = ''
for i in range(7):
for j in range(45):
bit = data[i][j]
if (4 - (j % 8)) < 0:
s += ' '
else:
if bit == 0:
s += '.'
if bit == 1:
s += 'o'

s += "\n"
print s

return json.dumps({
'success': True
}
), 200, {
'ContentType': 'application/json'
}


if __name__ == "__main__":
app.run()
2 changes: 1 addition & 1 deletion towers
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require_relative 'lib/towers'
INTERVAL = 0.3

def hit_phat towers
url = 'http://192.168.1.115:5000/lights'
url = 'http://localhost:5000/lights'
payload = {
data: towers.matrix
}
Expand Down

0 comments on commit 88508f5

Please sign in to comment.