mirror of
https://github.com/wolfswolke/DeathGarden_API_Rebirth.git
synced 2026-10-27 00:29:44 -05:00
Added Elasticsearch Handler for better Log output/visibility of error messages and infos.
Reformated API endpoints to be in a better order. Updated .gitignore to exclude config. Added requirments.txt Removed handler.py
This commit is contained in:
14
src/logic/Elasticsearch_handler.py
Normal file
14
src/logic/Elasticsearch_handler.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from datetime import datetime, date
|
||||
from elasticsearch import Elasticsearch
|
||||
import json
|
||||
|
||||
|
||||
def es_upload(server, index, log_message):
|
||||
if type(log_message) is not dict:
|
||||
log_message = {"steam_key": log_message}
|
||||
log_message["timestamp"] = datetime.utcnow().isoformat()
|
||||
es = Elasticsearch(server)
|
||||
data = json.dumps(log_message)
|
||||
response = es.index(index=index, body=data, headers={'Content-Type': 'application/json;charset=UTF-8'})
|
||||
document_id = response['_id']
|
||||
print("Uploaded dictionary with ID:", document_id)
|
||||
@@ -1,5 +0,0 @@
|
||||
|
||||
def post_handler(data):
|
||||
print("Post respond:")
|
||||
print(data)
|
||||
print("END OF RESPOND")
|
||||
Reference in New Issue
Block a user