-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(examples): Added a sample script to send HTTP requests to the fr…
…b-voe server
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Define any parameters you want to send along with the request (if any) | ||
payload = { | ||
"kind": "detection", | ||
"date": "2025-01-13 16:55:08.844845", | ||
"email": "[email protected]", | ||
"semi_major": 0.026, | ||
"semi_minor": 0.013, | ||
"sampling_time": 0.001, | ||
"bandwidth": 400, | ||
"central_frequency": 600, | ||
"npol": 2, | ||
"bits_per_sample": 2, | ||
"gain": 1.76, | ||
"tsys": 25.0, | ||
"internal_id": "20210826A", | ||
"dm": 298.53, | ||
"dm_error": 0.01, | ||
"width": 4.8, | ||
"snr": 13.8, | ||
"flux": 4.9, | ||
"right_ascension": 55.2938, | ||
"declination": 14.2049, | ||
"pos_error_deg_95": 0.1, | ||
"importance": 0.9979, | ||
"website": "https://www.example.com", | ||
"tns_name": "FRB20210826A", | ||
"update_message": "", | ||
} | ||
|
||
import requests | ||
import logging | ||
|
||
# Enable logging | ||
logging.basicConfig(level=logging.DEBUG) | ||
|
||
# Define the IP address you want to send the request to | ||
ip_address = '142.157.211.4:8000' | ||
# Define the endpoint or URL path | ||
endpoint = '/voe' | ||
|
||
# Construct the full URL | ||
url = f'http://{ip_address}{endpoint}' | ||
|
||
# Send a POST request | ||
response = requests.post(url, data=payload) | ||
|
||
# Check if the request was successful (status code 200) | ||
if response.status_code == 200: | ||
# Print the response content | ||
print("It worked!", response.text) | ||
else: | ||
# Print an error message | ||
print(f"Error: {response.status_code}") |