Hello -
Hope all is well. I am new to the Anvil Community and needing help in understanding how best to set up an http_endpoint [“POST”] which logs data to a Data Table.
I am pulling data from a streaming internet infrastructure data source that allows sending to a POST endpoint via a webhook. To be clear, the data source is not “streaming” in the sense that there is always data being pushed. Sometimes I will get one alert every 30 seconds, another day I might only get one alert the entire day.
Right now I am attempting to listen for new alerts via the below endpoint and auto-update my Data Table. I have watched 5-6 alerts in my terminal so i know data are posting. Yet looking at my Data Table I see nothing. I have confirmed that my Data Table has the same columns as shown below and allows the server module read/write access.
Within my streaming data source I provided the public URL for the endpoint to my streaming data source, but I’m not seeing new alerts posting to my Data Table.
@anvil.server.http_endpoint('/new_alert',methods=['POST'])
def internet_stream(**response):
return app_tables.bb_internet.add_row(asn=response.get('asn',None),hostnames=response.get('hostnames', None),
org=response.get('org', None), port=response.get('port', None),
transport=response.get('transport',None), isp=response.get('isp', None),
referring_website=response.get('bb_internet', None).get('options', None).get('hostname', None),
module_name=response.get('bb_internet',None).get('module', None), vulns=response.get('opts',None).get('vulns',None),
city=response.get('location',None).get('city',None),
longitude=response.get('location',None).get('longitude',None),
latitude=response.get('location',None).get('latitude',None), country_code=response.get('location',None).get('country_code',None),
country_name=response.get('location',None).get('country_name',None), area_code=response.get('location',None).get('area_code',None),
os=response.get('os', None), ip_str=response.get('ip_str',None), timestamp=response.get('timestamp',None),
domains=response.get('domains',None))
In addition to the above code I have also attempted to set up a background task that routinely checks the endpoint, set up a timer in the client-side code to check the endpoint every .5 seconds, etc. In both of those attempts I received a server timeout error.
Appreciate in advance your help with this.
Thanks,
Michael