summaryrefslogtreecommitdiffstats
path: root/clover/controller/control/control.py
blob: 54f713a2d2da795d807d517709ca906a631250fe (plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Copyright (c) Authors of Clover
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0

from flask import Flask, request, jsonify
from views.dashboard import simple_page
from api.collector import collector
from api.snort import snort
from api.nginx import nginx
from api.jmeter import jmeter
from api.file_upload import file_upload
import logging

logging.basicConfig(filename='flask.log', level=logging.DEBUG)

application = Flask(__name__)

try:
    # Register blueprints
    application.register_blueprint(simple_page)
    application.register_blueprint(collector)
    application.register_blueprint(snort)
    application.register_blueprint(nginx)
    application.register_blueprint(jmeter)
    application.register_blueprint(file_upload)
except Exception as e:
    logging.debug(e)


@application.route("/")
def test():
    return "<h1 style='color:blue'>clover-controller up</h1>"


@application.route("/config_server/<server>")
def show_server(server):
    return "User %s" % server


@application.route("/get_json", methods=['GET', 'POST'])
def get_json():
    try:
        content = request.json
        cmd = content["cmd"]
        resp = jsonify({"cmd": cmd})
    except Exception as e:
        resp = e
    return resp


if __name__ == "__main__":
    application.run(host='0.0.0.0')