Add location search and polish running route planner
This commit is contained in:
+14
-1
@@ -6,7 +6,7 @@ from flask_login import current_user, login_required
|
||||
|
||||
from .extensions import db, limiter
|
||||
from .models import PlannedRoute
|
||||
from .planner_engine import PlannerError, generate, validate
|
||||
from .planner_engine import PlannerError, generate, search_locations, validate
|
||||
|
||||
planner = Blueprint("planner", __name__, url_prefix="/routes")
|
||||
|
||||
@@ -62,6 +62,19 @@ def candidates():
|
||||
return jsonify(routes=[serialise(row) for row in rows], warnings=warnings)
|
||||
|
||||
|
||||
@planner.post("/search")
|
||||
@login_required
|
||||
@limiter.limit("30 per minute; 600 per day")
|
||||
def search():
|
||||
try:
|
||||
locations = search_locations(
|
||||
request.get_json(silent=True), current_app.config.get("ORS_API_KEY")
|
||||
)
|
||||
except PlannerError as error:
|
||||
return jsonify(error=str(error)), 400
|
||||
return jsonify(locations=locations)
|
||||
|
||||
|
||||
@planner.get("/<int:route_id>")
|
||||
@login_required
|
||||
def detail(route_id):
|
||||
|
||||
Reference in New Issue
Block a user