forked from xinghalo/PathPlanning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
51 lines (41 loc) · 1.05 KB
/
run.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
45
46
47
48
49
50
51
from flask import Flask
from flask import render_template
from flask import make_response
from flask import request
from flask import jsonify
import json
from planning import astar
from utils import parameter_utils
import numpy
app = Flask(__name__)
@app.route("/demo1")
def hello():
"""
最简单的例子
:return:
"""
return render_template('demo1.html')
@app.route("/demo2")
def demo2():
"""
自定义墙体
:return:
"""
return render_template('demo2.html')
@app.route("/find/path", methods = ['Post'])
def find_path():
"""
调取对应的算法查询路径
:return:
"""
params = json.loads(request.data.decode("utf-8"))
print(params)
type = params['type']
start = parameter_utils.str2tuple(params['start'])
goal = parameter_utils.str2tuple(params['goal'])
result = {"data":[]}
if type == 'a*':
result['data'] = astar.astar(numpy.array(params['map']), start, goal)
return make_response(jsonify(result))
if __name__ == "__main__":
app.run(host="127.0.0.1", port=5000)