Merge branch 'main' into feature/ttn-location-algo
This commit is contained in:
commit
6300004ec3
@ -15,7 +15,6 @@ def send_post_request(uri, data):
|
||||
except requests.exceptions.RequestException as e:
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Read JSON files and send them as POST requests to simulate a webhook request."
|
||||
@ -41,6 +40,16 @@ def main():
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
if args.mode == "send_one":
|
||||
if os.path.isfile(args.directory) and args.directory.endswith(".json"):
|
||||
with open(args.directory, "r", encoding="utf-8") as file:
|
||||
try:
|
||||
data = json.load(file)
|
||||
print(f"Sending {args.directory} to {args.uri}")
|
||||
send_post_request(args.uri, data)
|
||||
except json.JSONDecodeError as e:
|
||||
print(f"Error reading {args.directory}: {e}")
|
||||
return
|
||||
|
||||
if not os.path.exists(args.directory):
|
||||
print(f"Directory {args.directory} does not exist.")
|
||||
|
Loading…
Reference in New Issue
Block a user