[API] minor fix

This commit is contained in:
Sam 2021-11-30 09:02:41 +01:00
parent 9555b5cc1e
commit a1c5c344a6
2 changed files with 6 additions and 7 deletions

View File

@ -1112,7 +1112,6 @@ class TestUserPicture(ApiTestCaseMixin):
) )
data = json.loads(response.data.decode()) data = json.loads(response.data.decode())
print('data', data)
assert response.status_code == 413 assert response.status_code == 413
assert 'fail' in data['status'] assert 'fail' in data['status']
assert ( assert (
@ -1144,7 +1143,6 @@ class TestUserPicture(ApiTestCaseMixin):
) )
data = json.loads(response.data.decode()) data = json.loads(response.data.decode())
print('data', data)
assert response.status_code == 413 assert response.status_code == 413
assert 'fail' in data['status'] assert 'fail' in data['status']
assert ( assert (

View File

@ -2,7 +2,7 @@ import json
import os import os
import shutil import shutil
from datetime import timedelta from datetime import timedelta
from typing import Any, Dict, List, Optional, Tuple, Union from typing import Dict, List, Optional, Tuple, Union
import requests import requests
from flask import ( from flask import (
@ -10,7 +10,6 @@ from flask import (
Response, Response,
current_app, current_app,
request, request,
send_file,
send_from_directory, send_from_directory,
) )
from sqlalchemy import exc from sqlalchemy import exc
@ -770,7 +769,7 @@ def download_workout_gpx(
@workouts_blueprint.route('/workouts/map/<map_id>', methods=['GET']) @workouts_blueprint.route('/workouts/map/<map_id>', methods=['GET'])
def get_map(map_id: int) -> Any: def get_map(map_id: int) -> Union[HttpResponse, Response]:
""" """
Get map image for workouts with gpx Get map image for workouts with gpx
@ -803,8 +802,10 @@ def get_map(map_id: int) -> Any:
workout = Workout.query.filter_by(map_id=map_id).first() workout = Workout.query.filter_by(map_id=map_id).first()
if not workout: if not workout:
return NotFoundErrorResponse('Map does not exist.') return NotFoundErrorResponse('Map does not exist.')
absolute_map_filepath = get_absolute_file_path(workout.map) return send_from_directory(
return send_file(absolute_map_filepath) current_app.config['UPLOAD_FOLDER'],
workout.map,
)
except Exception as e: except Exception as e:
return handle_error_and_return_response(e) return handle_error_and_return_response(e)