I want to check if the json file is empty. Where in the code do i check that properly? This is my code:
import os
import sys
import traceback
import json
import requests
from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv())
try:
API_ENDPOINT = os.getenv('OVERPASS_API_ENDPOINT', 'http://overpass.osm.ch/api/interpreter')
query = "".join(sys.stdin.readlines())
r = requests.get(API_ENDPOINT, params={'data': query})
print(json.dumps(r.json(), sort_keys=True, indent=2))
except Exception as e:
print("Error: %s" % e, file=sys.stderr)
print(traceback.format_exc(), file=sys.stderr)
sys.exit(1)
Thanks for your help.