File size: 618 Bytes
5cd41bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import json
import os
import utils.api_client

# Import secrets
whisp_api_key = os.environ.get("WHISP_API_KEY")


# Define main function to fetch geojson, do API call and get statistics

def get_statistics(file): 

    # Open the geojson file uploaded
    if file is None:
        return "Geojson file empty"
    
    try:
        with open(file, 'r', encoding='utf-8') as f:
            geojson_file = json.load(f)
    except Exception as e:
        return {"error": str(e)}

    # Do the API call
    whisp_response = utils.api_client.whisp_request(geojson_file, api_key=whisp_api_key)

    return whisp_response