Example #1
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