mirror of
https://github.com/projecthorus/sondehub-infra.git
synced 2025-01-19 11:16:42 +00:00
Add filename
This commit is contained in:
parent
1c1173ccf4
commit
06cfbffc8f
@ -353,6 +353,7 @@ def get_telem_full(event, context):
|
|||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
filename = f'{event["pathParameters"]["payload_callsign"]}.json'
|
||||||
content_type = "application/json"
|
content_type = "application/json"
|
||||||
# convert to CSV if requested
|
# convert to CSV if requested
|
||||||
if (
|
if (
|
||||||
@ -362,6 +363,7 @@ def get_telem_full(event, context):
|
|||||||
):
|
):
|
||||||
import csv
|
import csv
|
||||||
content_type = "text/csv"
|
content_type = "text/csv"
|
||||||
|
filename = f'{event["pathParameters"]["payload_callsign"]}.csv'
|
||||||
csv_keys = list(set().union(*(d.keys() for d in data)))
|
csv_keys = list(set().union(*(d.keys() for d in data)))
|
||||||
csv_keys.remove("datetime")
|
csv_keys.remove("datetime")
|
||||||
csv_keys.insert(0,"datetime") # datetime should be at the front of the CSV
|
csv_keys.insert(0,"datetime") # datetime should be at the front of the CSV
|
||||||
@ -369,6 +371,7 @@ def get_telem_full(event, context):
|
|||||||
fc = csv.DictWriter(csv_output, fieldnames=csv_keys)
|
fc = csv.DictWriter(csv_output, fieldnames=csv_keys)
|
||||||
fc.writeheader()
|
fc.writeheader()
|
||||||
fc.writerows(data)
|
fc.writerows(data)
|
||||||
|
|
||||||
data = csv_output.getvalue()
|
data = csv_output.getvalue()
|
||||||
elif (
|
elif (
|
||||||
"queryStringParameters" in event
|
"queryStringParameters" in event
|
||||||
@ -376,6 +379,7 @@ def get_telem_full(event, context):
|
|||||||
and event["queryStringParameters"]['format'] == "kml"
|
and event["queryStringParameters"]['format'] == "kml"
|
||||||
):
|
):
|
||||||
content_type = "application/vnd.google-earth.kml+xml"
|
content_type = "application/vnd.google-earth.kml+xml"
|
||||||
|
filename = f'{event["pathParameters"]["payload_callsign"]}.kml'
|
||||||
|
|
||||||
# Extract some basic flight info for use in KML Metadata
|
# Extract some basic flight info for use in KML Metadata
|
||||||
callsign = str(event["pathParameters"]["payload_callsign"])
|
callsign = str(event["pathParameters"]["payload_callsign"])
|
||||||
@ -453,7 +457,7 @@ def get_telem_full(event, context):
|
|||||||
"statusCode": 200,
|
"statusCode": 200,
|
||||||
"headers": {
|
"headers": {
|
||||||
"Content-Encoding": "gzip",
|
"Content-Encoding": "gzip",
|
||||||
"Content-Disposition": "attachment",
|
"Content-Disposition": f'attachment; filename="{filename}"',
|
||||||
"Content-Type": content_type
|
"Content-Type": content_type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user