Example #1
0
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""):
        queue.put(line)
    print "Output listener stopped."
    out.close()


# Create subdirectory of root
def dir_uuid(root, fileid):
    dir = os.path.join(root, fileid)
    os.mkdir(dir)
    return dir
Example #2
0
__version__ = "0.1.0"


import datetime

from flask import Flask, render_template
from flask.ext.classy import FlaskView
import redis
import humanize


app = Flask(__name__)

app.config["REDIS_HOST"] = "redis"
app.config["REDIS_PORT"] = 6379
app.config["TIMEOUT"] = None
app.config["UPDATE_INTERVAL"] = None
app.config["GOOGLE_ANALYTICS_TRACKING_ID"] = None
app.config.from_pyfile("/etc/nymph/config.py", silent=True)

r = redis.StrictRedis(app.config["REDIS_HOST"], app.config["REDIS_PORT"])


# noinspection PyMethodMayBeStatic
class AppListView(FlaskView):

    route_base = "/"

    def index(self):
        app_ids = list(map(bytes.decode, r.zrevrange("zset.date.app.id", 0, -1)))
        apps = [