Spaces:
Running
Running
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 | |