Skip to content

Commit

Permalink
feat(examples): Added a sample script to send HTTP requests to the fr…
Browse files Browse the repository at this point in the history
…b-voe server
  • Loading branch information
tabbott36 committed Oct 25, 2024
1 parent bab3d9e commit dbc169e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ Note: MongoDB is set to run at port 27017 by default. Ensure nothing is running

# Getting Started

## Configuring Your Observatory
The `frb-voe` software operates using HTTP requests, in order to initiate the publication of a VOEvent from your observatory, a correctly formatted HTTP request must be sent to your `frb-voe` server. This request is required to contain the burst metadata (for "detection" and "subsequent" type VOEvents, or an update message or internal ID for "update" and "retraction" type VOEvents, respectively). This can be accomplished manually, or from an automated request being sent from the host observatory to the `frb-voe` server upon detection of a new event. An example script demonstrating this is provided in the `examples` directory.

## Environment Variables

Certain aspects of the service (such as SMTP servers and interactions with the TNS) require sensitive information such as passwords and API keys. To use these services, it is recommended that you pass these secrets as environment variables. These must be added to your bash profile with the following naming convention.
Expand Down
53 changes: 53 additions & 0 deletions examples/send_voe.py
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}")

0 comments on commit dbc169e

Please sign in to comment.