forked from trew/PokemonGoMapNotifier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
32 lines (23 loc) · 815 Bytes
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import logging
import logging.config
import json
import yaml
from notifier.manager import NotifierManager
class Receiver():
def __init__(self, config):
# Setup logging
with open('logging.yaml') as f:
logging.config.dictConfig(yaml.load(f))
logging.getLogger().setLevel(logging.INFO)
# Remove logging of each sent request to discord
logging.getLogger('requests').setLevel(logging.WARNING)
self.notifiermanager = NotifierManager(config)
self.notifiermanager.start()
def process(self, request_body):
data = json.loads(request_body)
if type(data) == dict:
self.notifiermanager.enqueue(data)
else:
for frame in data:
self.notifiermanager.enqueue(frame)
return ""