예제 #1
0
from flask import Flask, request, json
from core import EventManager
from utilits import settings

app = Flask(__name__)

manager = EventManager()
manager.initialization_handlers()


@app.route('/handler/vk')
def handler_vk():
    # Обработчик запросов от вк
    try:
        data = json.loads(request.get_data())
    except:
        return "Data error", 200
    vk_settings = settings('vk')
    if data['type'] == 'confirmation':
        return vk_settings['code']
    if data['secret'] != vk_settings['secret'] or int(
            data['group_id']) not in vk_settings['groups']:
        return "Verification error", 200
    manager.new_event(data)
    return "Ok", 200


if __name__ == '__main__':
    app.run()
예제 #2
0
from core import EventManager

EventManager().initialization_handlers()