-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
36 lines (24 loc) · 765 Bytes
/
app.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
from flask import Flask, request
import json
from solve import solve, turn
import pycuber as pc
app = Flask(__name__)
@app.route("/")
def run():
return "<h1 style='color:blue'>Hello There!</h1>"
# @app.route("/solve")
# def run():
# return "<h1 style='color:blue'>Hello There!</h1>"
@app.route("/solve",methods=['POST'])
def predict():
content = request.get_json()
target_cube = turn(content)
if type(target_cube) == "str":
return json.dumps([False, "Invalid input"])
if target_cube.is_valid() == False:
return json.dumps([False, "Invalid input"])
is_solved, actions = solve(target_cube)
results = [is_solved, actions]
return json.dumps(results)
if __name__ == "__main__":
app.run(host='0.0.0.0')