#!/usr/bin/env python
# -*- coding: utf-8 -*-

from flask import Flask, render_template, flash, redirect, request, url_for, Markup
import glob
import os
import sys
import subprocess, signal
import stat

app = Flask(__name__)
app.secret_key = "some_secret"
app.path = "/mnt/Movies"
app.fifo = "/home/pi/omx.pipe"


def fifo():
    if os.path.exists(app.fifo):
        pass
    else:
        os.system("mkfifo " + app.fifo)


@app.route("/")
def home():
    if os.path.exists(app.path):
        os.chdir(app.path)
    else:
        sys.exit("Check Path")

    names = []
Example #2
0
import bitsets
import concurrent.futures
import flask
import requests

from flask import Flask, request

import index


app = Flask(__name__)
logging.getLogger("concurrent.futures").addHandler(logging.StreamHandler())
num_clients = 3
port = 9090
app.indexed = False
app.path = None

session = requests.Session()
pool = concurrent.futures.ThreadPoolExecutor(num_clients + 1)


def request_clients(path, params=None):
    results = []
    for i in range(1, num_clients + 1):
        url = "http://localhost:%d%s" % (port + i, path)
        results.append(pool.submit(session.get, *(url,), params=params))
    return [result.result() for result in results]


def _indexer(path):
    ix = index.Index(app.id)