summaryrefslogtreecommitdiffstats
path: root/Lasers_und_stuff/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lasers_und_stuff/main.py')
-rw-r--r--Lasers_und_stuff/main.py43
1 files changed, 41 insertions, 2 deletions
diff --git a/Lasers_und_stuff/main.py b/Lasers_und_stuff/main.py
index 4869d96..15ab4e3 100644
--- a/Lasers_und_stuff/main.py
+++ b/Lasers_und_stuff/main.py
@@ -10,6 +10,7 @@ import flask
import threading
import os
import signal
+import json
from pygame.locals import *
from Cannon import CannonController
from Cannon import Gunpoint
@@ -18,9 +19,47 @@ app = flask.Flask(__name__)
app.debug = True
pygame.init()
+cannon = None
+
+@app.route("/left/<int:amount>")
+def move_left(amount):
+ cannon.move_left(amount)
+ return "OK"
+
+@app.route("/right/<int:amount>")
+def move_right(amount):
+ cannon.move_right(amount)
+ return "OK"
+
+@app.route("/up/<int:amount>")
+def move_up(amount):
+ cannon.move_up(amount)
+ return "OK"
+
+@app.route("/down/<int:amount>")
+def move_down(amount):
+ cannon.move_down(amount)
+ return "OK"
+
+@app.route("/status")
+def status():
+ return json.dumps(cannon.get_data())
+
@app.route("/")
def root():
- return "COCKS"
+ return """<html>
+ <head>
+ <title>Turret!</title>
+ </head>
+ <body>
+ <div style="width: 400px; height: 400px; margin-top: -200px; margin-left: -200px; position: absolute; top: 50%; left: 50%;">
+ <a href="/up/20">Up</a>
+ <a href="/down/20">Down</a>
+ <a href="/left/20">Left</a>
+ <a href="/right/20">Right</a>
+ </div>
+ </body>
+</html>"""
def main():
#create the screen
@@ -35,7 +74,7 @@ def main():
colors = [GRAY, VIOLET, RED, GREEN, BLUE, VERYLIGHT]
-
+ global cannon
cannon = CannonController()