-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
34 lines (28 loc) · 838 Bytes
/
app.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
33
34
import json
import shutil
import config
import zlib
import string
import random
from inspec import get_inspec_analysis
from flask import Flask
from flask import request
from flask import Response
app = Flask(__name__)
@app.route('/')
def hello_world():
return { "status" : True }
@app.route('/run_profile', methods=["POST"])
def run_profile():
try:
return get_inspec_analysis(id_generator, request.json)
except Exception as e:
print("Errore per {}: {}".format(host, str(e)))
return { "status": False, "message": str(e) }
def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
return ''.join(random.choice(chars) for _ in range(size))
if __name__ == '__main__':
app.run(debug = config.WEB_DEBUG,
host = config.WEB_HOST,
port = config.WEB_PORT,
threaded=True)