-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathremoteAPI.py
44 lines (36 loc) · 1.18 KB
/
remoteAPI.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from flask import Flask, render_template, url_for, redirect, request
from controller import Controller
app = Flask(__name__, static_url_path='', static_folder='images/current_image')
controller = Controller()
@app.route("/")
def index():
controller.create_temp_photo()
return render_template ('index.html', image_path = controller.get_photoname())
@app.route("/forward")
def forward():
controller.up()
return redirect('/')
@app.route("/piv_left")
def piv_left():
controller.piv_left()
return redirect('/')
@app.route("/piv_right")
def piv_right():
controller.piv_right()
return redirect('/')
@app.route("/ai_move")
def ai_move():
"this route is expected to be called with the"
"origins ML image upload URL as a query param"
host_url = request.args['host_url']
controller.create_temp_photo()
img_path = controller.get_img_path()
print(img_path)
print(host_url)
move = controller.get_server_move(img_path, host_url)
if move == 'forward': controller.up()
elif move == 'pivot right': controller.piv_right()
else: controller.piv_left()
return redirect('/')
if __name__ == "__main__":
app.run(host='0.0.0.0', port=5000)