From 223a2b12b61dc5e108cb3f3d3f70a33e515746c2 Mon Sep 17 00:00:00 2001 From: fordprefect Date: Sat, 18 Apr 2020 15:15:41 +0200 Subject: [PATCH] gpx file download done properly --- websearch.py | 42 +++++++----------------------------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/websearch.py b/websearch.py index 0105a1e..eae5b2c 100755 --- a/websearch.py +++ b/websearch.py @@ -16,6 +16,7 @@ import random import os import sys assert sys.version_info >= (3, 6), "At least Python 3.8 required due to fStrings. Replace all f\"…\" and comment this line to enable running in lower versions (but really, you should just update your Python version…)." +import base64 ##################################### ######## configuration @@ -71,7 +72,7 @@ args["outputfilename"] = outputfilename searchresult = osmsearch.OSMSearch(args) gpxcontent = searchresult.gpxfile.to_xml() -gpxcontent_escaped = searchresult.gpxfile.to_xml().replace("\\", "\\\\").replace("'", "\\'").replace('"', '\\"') +gpxcontent_base64 = base64.b64encode(gpxcontent.encode("utf-8")).decode("utf-8") print(""" @@ -80,20 +81,6 @@ print(""" OSM search to GPX -
@@ -101,11 +88,11 @@ function download_file(filename, text) {

Success

-Copy file content from here: -
- +""" + f""" +Download GPX file here +

Return to search page @@ -116,18 +103,3 @@ OSMsearchToGPX - ein Service von dukun.de """) -# TODO download button does not work this way! -#""" -#
-#or (requires enabled JavaScript). -# -#

-#Return to search page -# -#
-#
-#OSMsearchToGPX - ein Service von dukun.de -#
-# -# -#""".format(gpxcontent=gpxcontent_escaped))