Example #1
0
#!/usr/env/bin python

import os

from flask import Flask
from flask.ext.misaka import Misaka
from lib import filters
from themes import themes

from flask.ext.cors import CORS

theme = os.environ.get("THEME", "default")

print themes
blog = Flask(__name__, static_folder=themes[theme]["static"], template_folder=themes[theme]["templates"])
CORS(blog)
Misaka(blog)

blog.config["FREEZER_RELATIVE_URLS"] = True
blog.config["MONGODB_DATABASE_URI"] = "mongodb://localhost:27017"
blog.config["BASE_DIR"] = os.path.abspath(os.path.dirname(__file__))
blog.jinja_env.filters["human_readable_date"] = filters.human_readable_date
blog.jinja_env.filters["clean_date"] = filters.clean_date

import views

print """
Running on theme {}. THEME='<THEME_NAME>' python run.py
""".format(
    theme, ", ".join(themes.keys())
)
Example #2
0
#!flask/bin/python
from flask import Flask, request, render_template, send_from_directory, jsonify
from flask.ext.bootstrap import Bootstrap
from src.transcriptionprocessor import TranscriptionProcessor
from src.audioprocessor import AudioProcessor
from src.filepathgenerator import gen_file_path
from src.filedisposer import file_disposer
import simplejson, traceback, json, os, shutil
from test.src import test_conf
from test.src.testdatacollector import test_data_collector

application = Flask(__name__)
application.config["TRANSCRIPTIONS"] = {}
application.config["BASE_DIR"] = os.getcwd()
application.config["USER_FILES"] = os.path.join(os.getcwd(), "user")
bootstrap = Bootstrap(application)


@application.route("/", methods=["GET", "POST"])
def index():
    return render_template("home.html")


@application.route("/transcribe", methods=["GET", "POST"])
def transcription():
    if request.method == "POST":
        if "transcriptionfile" in request.files.keys()[0]:
            if request.remote_addr in application.config["TRANSCRIPTIONS"]:
                return render_template("audio.html")
            else:
                tp = TranscriptionProcessor(request)