Skip to content
Snippets Groups Projects
Commit b97a5f09 authored by Herman Andersen Dyrkorn's avatar Herman Andersen Dyrkorn
Browse files

get location and refactor init.py

parent e70b6925
No related branches found
No related tags found
1 merge request!22Resolve "refactor location endpoint"
...@@ -18,13 +18,13 @@ api = Api(app) ...@@ -18,13 +18,13 @@ api = Api(app)
from api.endpoints.login import Login from api.endpoints.login import Login
from api.endpoints.user import UserEndpoint from api.endpoints.user import UserEndpoint
from api.endpoints.location import LocationEndpoint
from api.endpoints.matchsalamander import MatchSalamander from api.endpoints.matchsalamander import MatchSalamander
from api.endpoints.registerlocation import RegisterLocation
from api.endpoints.findsalamanderinfo import FindSalamanderInfo from api.endpoints.findsalamanderinfo import FindSalamanderInfo
api.add_resource(Login, "/login") api.add_resource(Login, "/login")
api.add_resource(UserEndpoint, "/user") api.add_resource(UserEndpoint, "/user")
api.add_resource(LocationEndpoint, "/location")
api.add_resource(MatchSalamander, "/matchSalamander") api.add_resource(MatchSalamander, "/matchSalamander")
api.add_resource(RegisterLocation, "/registerLocation")
api.add_resource(FindSalamanderInfo, "/findSalamanderInfo") api.add_resource(FindSalamanderInfo, "/findSalamanderInfo")
No preview for this file type
...@@ -10,7 +10,7 @@ COORDINATES_REGEX = "^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),\s*[-+]?(180(\.0+)?|((1[ ...@@ -10,7 +10,7 @@ COORDINATES_REGEX = "^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),\s*[-+]?(180(\.0+)?|((1[
# findSalamanderInfo endpoint # findSalamanderInfo endpoint
class RegisterLocation(Resource): class LocationEndpoint(Resource):
@staticmethod @staticmethod
@jwt_required @jwt_required
def post(): def post():
...@@ -29,6 +29,16 @@ class RegisterLocation(Resource): ...@@ -29,6 +29,16 @@ class RegisterLocation(Resource):
else: else:
return jsonify({"message": "wrong data"}) return jsonify({"message": "wrong data"})
@staticmethod
@jwt_required
def get():
locations = db.session.query(Location).all()
location_list = []
for location in locations:
loc = {"id": location.id, "radius": location.radius, "name": location.name, "coordinates": location.coordinates}
location_list.append(loc)
return jsonify(location_list)
def create_directory_folders(location): def create_directory_folders(location):
dir_smooth_male = "images/" + location + "/smooth_newt/" + "male/" dir_smooth_male = "images/" + location + "/smooth_newt/" + "male/"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment