Example #1
# flask
from flask import Flask, jsonify, render_template, request, Response, url_for
from werkzeug import secure_filename

# threading
from threading import Thread
from Queue import Queue, Empty

# jinja templating
from jinja2 import Environment
from jinja2.loaders import FileSystemLoader

# configuration
app = Flask(__name__)
app.config["UPLOAD_FOLDER"] = "upload"
app.config["DOWNLOAD_FOLDER"] = "static/download"
app.config["TIMEOUT"] = 60

# Separate thread which performs blocking reads on stdout and adds new lines to queue
def enqueue_output(out, queue):
    for line in iter(out.readline, b""):
    print "Output listener stopped."

# Create subdirectory of root
def dir_uuid(root, fileid):
    dir = os.path.join(root, fileid)
    return dir
Example #2
# and send_from_directory will help us to send/show on the
# browser the file that the user just uploaded
from flask import Flask, render_template, request, redirect, url_for, send_from_directory
from werkzeug.utils import secure_filename
import random
from detect import dhcdetect
from detect.dhcdetect import leasepath
from scan import nmap

# Initialize the Flask application
app = Flask(__name__)

# This is the path to the upload directory
app.config["UPLOAD_FOLDER"] = "uploads/"
app.config["DOWNLOAD_FOLDER"] = "downloads/"
# These are the extension that we are accepting to be uploaded
app.config["ALLOWED_EXTENSIONS"] = {"conf", "rules"}

# For a given file, return whether it's an allowed type or not
def allowed_file(filename):
    return "." in filename and filename.rsplit(".", 1)[1] in app.config["ALLOWED_EXTENSIONS"]

# This route will show a form to perform an AJAX request
# jQuery is loaded to execute the request and update the
# value of the operation
def index():
    iplist = []