API - add user agent when generating static map - fix #210

This commit is contained in:
Sam
2022-07-13 09:39:33 +02:00
parent 66a24b3f4f
commit 0eaae0e171
3 changed files with 75 additions and 4 deletions

View File

@ -4,6 +4,7 @@ from typing import List
from flask import current_app
from staticmap import Line, StaticMap
from fittrackee import VERSION
from fittrackee.files import get_absolute_file_path
@ -12,6 +13,7 @@ def generate_map(map_filepath: str, map_data: List) -> None:
Generate and save map image from map data
"""
m = StaticMap(400, 225, 10)
m.headers = {'User-Agent': f'FitTrackee v{VERSION}'}
if not current_app.config['TILE_SERVER']['DEFAULT_STATICMAP']:
m.url_template = current_app.config['TILE_SERVER']['URL'].replace(
'{s}.', ''