@@ -20,24 +20,24 @@ def on_post(request: FoundryRequest) -> FoundryResponse:
2020 try :
2121 # Store data in a collection
2222 # This assumes you've already created a collection named "event_logs"
23- json = {
23+ json = {
2424 "data" : event_data ,
2525 "timestamp" : int (time .time ())
2626 }
2727
2828 falcon = CustomStorage ()
2929
30- response = falcon .PutObject (body = json ,
30+ response = falcon .PutObject (body = json ,
3131 collection_name = "event_logs" ,
3232 object_key = "event_id"
3333 )
3434
3535 if response .status_code != 201 :
3636 return FoundryResponse (
37- code = create_response .status_code ,
37+ code = response .status_code ,
3838 errors = [FoundryAPIError (
39- code = create_response .status_code ,
40- message = f"Failed to store event: { create_response .text } "
39+ code = response .status_code ,
40+ message = f"Failed to store event: { response .text } "
4141 )]
4242 )
4343
@@ -51,7 +51,7 @@ def on_post(request: FoundryRequest) -> FoundryResponse:
5151 return FoundryResponse (
5252 body = {
5353 "stored" : True ,
54- "record_id" : create_response .json ().get ("id" ),
54+ "record_id" : response .json ().get ("id" ),
5555 "recent_events" : query_response .json ().get ("resources" , [])
5656 },
5757 code = 200
@@ -61,3 +61,7 @@ def on_post(request: FoundryRequest) -> FoundryResponse:
6161 code = 500 ,
6262 errors = [FoundryAPIError (code = 500 , message = f"Error with collection: { str (e )} " )]
6363 )
64+
65+
66+ if __name__ == '__main__' :
67+ func .run ()
0 commit comments