# Import from standard library
import logging
from datetime import datetime

# Import from third-party
from flask import Flask, render_template, json, request, jsonify, session

# Import local files
import DAO.db_connect as db_connect
from config.config import ElasticConfig
from modules.nmap.process_nmap import processNmap, processNmapDetail

def nmap_detail():
    id = request.args.get('id')
    if id is None:
        return render_template('nmap-detail.html')
    else:
        try:
            es = db_connect.connect_elasticsearch()
            try:
                raw_data = es.get(index=ElasticConfig.NMAP_INDEX,
                                  doc_type="_doc", id=id)
                print(raw_data)
                processed_data = json.loads(processNmapDetail(raw_data))
            except:
                logging.exception(msg="Fail")
        except:
            logging.exception(msg="Fail")
    session['module'] = "nmap"
    session['overview'] = False
    return render_template('nmap-detail.html', response=processed_data)
# Import from standard library
import logging
from datetime import datetime

# Import from third-party
from flask import Flask, render_template, json, request, jsonify, session

# Import local files
import DAO.db_connect as db_connect
from config.config import ElasticConfig
from modules.nmap.process_nmap import processNmap, processNmapDetail

def nmap_detail():
    id = request.args.get('id')
    if id is None:
        return render_template('nmap-detail.html')
    else:
        try:
            es = db_connect.connect_elasticsearch()
            try:
                raw_data = es.get(index=ElasticConfig.NMAP_INDEX,
                                  doc_type="_doc", id=id)
                print(raw_data)
                processed_data = json.loads(processNmapDetail(raw_data))
            except:
                logging.exception(msg="Fail")
        except:
            logging.exception(msg="Fail")
    session['module'] = "nmap"
    session['overview'] = False
    return render_template('nmap-detail.html', response=processed_data)
# Import from standard library # Import from third-party # Import local files