Example #1
0
    base_url="https://www.google.com/accounts/",
    authorize_url="https://accounts.google.com/o/oauth2/auth",
    request_token_url=None,
    request_token_params={"scope": "https://www.googleapis.com/auth/userinfo.email", "response_type": "code"},
    access_token_url="https://accounts.google.com/o/oauth2/token",
    access_token_method="POST",
    access_token_params={"grant_type": "authorization_code"},
    consumer_key=GOOGLE_CLIENT_ID,
    consumer_secret=GOOGLE_CLIENT_SECRET,
)


# This is the path to the upload directory
app.config["UPLOAD_FOLDER"] = "uploads/"
# These are the extension that we are accepting to be uploaded
app.config["ALLOWED_EXTENSIONS"] = set(["txt", "pdf", "png", "jpg", "jpeg", "gif"])


# 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
@app.route("/")
def index():
    return render_template("login.html")

Example #2
0
from flask import Flask, request
from flask import render_template
from kyrselastic import query_dsl
import unicodedata
from werkzeug import secure_filename
import os

app = Flask(__name__)


# This is the path to the upload directory
app.config["UPLOAD_FOLDER"] = "uploads/"
# These are the extension that we are accepting to be uploaded
app.config["ALLOWED_EXTENSIONS"] = set(["txt", "pdf", "png", "doc", "docx"])


def allowed_file(filename):
    return "." in filename and filename.rsplit(".", 1)[1] in app.config["ALLOWED_EXTENSIONS"]


@app.route("/")
@app.route("/index")
def index():
    return render_template("index.html")


@app.route("/personal")
def personal():
    return render_template("upload.html")

Example #3
0
import os, shutil, sys
from flask import Flask, request, render_template, jsonify, send_from_directory
from flask.ext.assets import Environment, Bundle
from werkzeug import secure_filename
from snipper import *
import file_helpers

# TODO: refactor this goddamn thing

app = Flask(__name__)
app.config["UPLOAD_FOLDER"] = file_helpers.UPLOAD_FOLDER
app.config["TMP_FOLDER"] = file_helpers.TMP_FOLDER
app.config["ALLOWED_EXTENSIONS"] = file_helpers.ALLOWED_EXTENSIONS
app.config["MAX_CONTENT_LENGTH"] = 20 * 1024 * 1024

# assets
assets = Environment(app)
js = Bundle(
    "vendor/js/jquery-1.7.2.min.js",
    "vendor/js/jquery-ui-1.8.21.custom.min.js",
    "vendor/js/jquery.iframe-transport.js",
    "vendor/js/jquery.fileupload.js",
    "vendor/js/underscore.js",
    "vendor/js/backbone.js",
    filters="rjsmin",
    output="gen/packed.js",
)

coffee = Bundle("assets/js/*.coffee", filters="coffeescript", output="gen/application.js")

sass = Bundle("assets/css/*.sass", filters="sass", output="gen/application.css")
    elif path.endswith(".gif"):
        filename = path.rsplit("/", 1)[1]
        return send_from_directory(app_root + "/templates/images/", filename)
    elif path.endswith(".jpg"):
        filename = path.rsplit("/", 1)[1]
        return send_from_directory(app_root + "/templates/images/", filename)
    elif path.endswith(".png"):
        filename = path.rsplit("/", 1)[1]
        return send_from_directory(app_root + "/data/", filename)


# This is the path to the upload directory
app.config["UPLOAD_FOLDER"] = "uploads/"
# These are the extension that we are accepting to be uploaded
# only csv files are allowed
app.config["ALLOWED_EXTENSIONS"] = set(["csv"])

# 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"]


@app.route("/")
def index_page():
    return render_template("index.html")


@app.route("/contact")
def contact_page():
    return render_template("contact.html")
Example #5
0
        # rules = grammarPrint

    return render_template(
        "dependency_graph.html", errors=errors, results=results, rules=rules, nodes=nodes
    )  # CREDIT: http://code.runnable.com/UiPcaBXaxGNYAAAL/how-to-upload-a-file-to-the-server-in-flask-for-python


# FOR UPLOADING FILES

# This is the path to the upload directory
# app.config['UPLOAD_FOLDER'] = 'C:/dissertation/Dissertation/flask/uploads/'
app.config["UPLOAD_FOLDER"] = "/public/homepages/s1245947/data/"

# These are the extension that we are accepting to be uploaded
app.config["ALLOWED_EXTENSIONS"] = set(["txt", "json"])

# 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"]


@app.route("/", methods=["GET", "POST"])
def render_upload():
    return render_template("upload.html")


# Route that will process the file upload
@app.route("/uploaded", methods=["POST"])
def upload():
    # definitions
from flask import Flask, render_template, request, redirect, url_for, send_from_directory, jsonify

# function definition to calculate the resource balancing factor given the resources utilized as input parameters (cpu,ram,network)
def skewness(cpu, ram, network):
    averagePMTotalResources = (cpu + ram + network) / 3.0
    skewFactor_one = (cpu / averagePMTotalResources - 1) ** 2
    skewFactor_two = (ram / averagePMTotalResources - 1) ** 2
    skewFactor_three = (network / averagePMTotalResources - 1) ** 2
    skewness = math.sqrt((skewFactor_one + skewFactor_two + skewFactor_three))
    return skewness


app = Flask(__name__)
app.config["UPLOAD_FOLDER"] = "uploads/"
app.config["ALLOWED_EXTENSIONS"] = set(["jpg", "jpeg", "png", "JPG"])


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


@app.route("/translate")
def translate():

    pmVal1 = request.args.get("textVal", 0, type=str)
    pmVal2 = request.args.get("textVal1", 0, type=str)
    pmVal3 = request.args.get("textVal2", 0, type=str)
    vmVal4 = request.args.get("textVal3", 0, type=str)
# We'll render HTML templates and access data sent by POST
# using the request object from flask. Redirect and url_for
# will be used to redirect the user once the upload is done
# 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 import secure_filename

# Initialize the Flask application
app = Flask(__name__)

# This is the path to the upload directory
app.config["UPLOAD_FOLDER"] = "uploads/"
# These are the extension that we are accepting to be uploaded
app.config["ALLOWED_EXTENSIONS"] = set(["apk"])

# 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
@app.route("/")
def index():
    return render_template("index.html")


# Route that will process the file upload
Example #8
0
app.config["ALLOWED_EXTENSIONS"] = set(
    [
        "mpeg",
        "ogg",
        "rtf",
        "docx",
        "odt",
        "micro",
        "c",
        "asm",
        "php",
        "css",
        "class",
        "java",
        "cs",
        "data",
        "py",
        "m4a",
        "mp3",
        "mp4",
        "zip",
        "json",
        "dta",
        "html",
        "js",
        "txt",
        "pdf",
        "png",
        "jpg",
        "jpeg",
        "gif",
    ]
)
Example #9
0
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
@app.route("/")
def index():
    iplist = []
    # Detect
    if os.path.exists(leasepath):
Example #10
0
# ALLOWED_EXTENSIONS = set(['jpg'])
# FACE_MEANS_FILE = 'mean.csv.txt'
# LANDMARKS_FILE = 'shape_predictor_68_face_landmarks.dat'


facerec = Flask(__name__)
fujs = FlaskUtilJs(facerec)
# facerec.config.from_pyfile('./config.cfg', silent=True)
# Configuration

facerec.config["DEBUG"] = True
facerec.config["SECRET_KEY"] = "development_key"
facerec.config["UPLOAD_FOLDER"] = "./data"
facerec.config["PROCESSED_FOLDER"] = "./data"
facerec.config["ALLOWED_EXTENSIONS"] = set(["jpg"])
facerec.config["FACE_MEANS_FILE"] = "mean.csv.txt"
facerec.config["LANDMARKS_FILE"] = "shape_predictor_68_face_landmarks.dat"

detector = NaiveDlib(
    os.path.join(facerec.config["UPLOAD_FOLDER"], facerec.config["FACE_MEANS_FILE"]),
    os.path.join(facerec.config["UPLOAD_FOLDER"], facerec.config["LANDMARKS_FILE"]),
    facerec,
)


def allowed_file(filename):
    return "." in filename and filename.rsplit(".", 1)[1] in facerec.config["ALLOWED_EXTENSIONS"]


@facerec.context_processor
Example #11
0
from flask.views import MethodView
from flask.ext.restful import Api
from flask.ext.httpauth import HTTPBasicAuth
from flask.ext.sqlalchemy import SQLAlchemy

app = Flask(__name__)
api = Api(app)
auth = HTTPBasicAuth()

try:
    import config

    app.config.from_object(config.Development)
except ImportError:
    app.config["ALLOWED_EXTENSIONS"] = {"txt", "mp4", "png", "jpg", "jpeg", "gif", "blend", "zip"}
    app.config["STORAGE_BUNDLES"] = "/tmp/bam_storage_bundles"


db = SQLAlchemy(app)
log = logging.getLogger("webservice")

from application.modules.resources import DirectoryAPI
from application.modules.resources import FileAPI

if os.environ.get("BAM_VERBOSE"):
    logging.basicConfig(level=logging.DEBUG)


@auth.get_password
def get_password(username):
Example #12
0
import os
import json
import urlparse
import base64
from flask import Flask, render_template, request, redirect, url_for, send_from_directory, json, jsonify
from werkzeug import secure_filename

app = Flask(__name__)

app.config["UPLOAD_FOLDER"] = "uploads/"

app.config["ALLOWED_EXTENSIONS"] = set(["svg", "vtk", "png", "jpg", "jpeg", "gif"])


def allowed_file(filename):
    return "." in filename and filename.rsplit(".", 1)[1] in app.config["ALLOWED_EXTENSIONS"]


@app.route("/")
def index():
    return render_template("etch3d.html")


# @app.route('/uploadFile')
# def uploadFile():
#     return render_template('index.html')


@app.route("/editor")
def editor():
    return render_template("editor.html")
Example #13
0
    db.set("SERVER_NAME", "localhost")

if not db.get("SOCKET_PORT"):
    db.set("SOCKET_PORT", 5001)

if not db.get("UPLOAD_FOLDER"):
    db.set("UPLOAD_FOLDER", "/var/www/yeti-cam/uploads")

if not db.get("CAM_LOG_FOLDER"):
    db.set("CAM_LOG_FOLDER", "/var/www/yeti-cam/logs")

if not db.get("ALLOWED_EXTENSIONS"):
    db.set("ALLOWED_EXTENSIONS", ["jpg", "jpeg", "txt", "h264"])

if not db.get(constants.GDRIVE_FOLDER):
    db.set(constants.GDRIVE_FOLDER, "")

if not db.get(constants.ENABLE_GDRIVE):
    db.set(constants.ENABLE_GDRIVE, False)

if not db.get(constants.STATUS):
    db.dcreate(constants.STATUS)

if not db.get(constants.LAST_CAM_UPDATE):
    db.set(constants.LAST_CAM_UPDATE, datetime.datetime.now().isoformat())

app.config["UPLOAD_FOLDER"] = db.get("UPLOAD_FOLDER")
app.config["CAM_LOG_FOLDER"] = db.get("CAM_LOG_FOLDER")
app.config["ALLOWED_EXTENSIONS"] = db.get("ALLOWED_EXTENSIONS")
app.config["SOCKET_PORT"] = db.get("SOCKET_PORT")
app.config["SECRET_KEY"] = "secret!"
Example #14
0
from flask import Flask, send_from_directory, flash, request, abort
from flask import render_template, redirect, session, url_for, json, g
from werkzeug import secure_filename, generate_password_hash, check_password_hash
from operator import itemgetter
from contextlib import closing

# configuration

app = Flask(__name__)
app.config.from_object(__name__)

app.config["DATABASE"] = os.path.join(app.root_path, "app.db")
app.config["DEBUG"] = True
app.config["SECRET_KEY"] = "I don't know what to keep my secret key"
app.config["UPLOAD_FOLDER"] = os.path.join(app.root_path, "uploads/")
app.config["ALLOWED_EXTENSIONS"] = ["mp3", "ogg", "wav", "aac"]


def connect_db():
    return sqlite3.connect(app.config["DATABASE"])


def init_db():
    with closing(connect_db()) as db:
        with app.open_resource("schema.sql", mode="r") as f:
            db.cursor().executescript(f.read())
        db.commit()


# @app.cli.command('initdb')
# def initdb_command():
Example #15
0
#! /usr/bin/python
import library
from query import *
import os
import time
import gc
from flask import Flask, request
import json
from flask import render_template
from flask.ext.api import status

app = Flask(__name__)
app.config["DEBUG"] = True
app.config["ALLOWED_EXTENSIONS"] = {"wav"}
music_database = library.Library()


def auto():
    """Tasks to be run automatically each time the program starts up."""
    music_database.load()
    if music_database.empty():
        info = "There is no songs in the library. Please import songs!"
        songs = None
    else:
        num = music_database.size()
        info = "Library loaded! Contains " + str(num) + " songs"
        songs = music_database.get_songs()
    music_database.export()
    return info, songs

Example #16
0
CloudMoss - Check against moss in the cloud.
"""

from flask import Flask, render_template, request, redirect, abort
from werkzeug import secure_filename

import os
import datetime
import moss
import zipfile
import requests

# Application Setup
app = Flask(__name__)
app.config["UPLOAD_DIR"] = "uploads"
app.config["ALLOWED_EXTENSIONS"] = set(["zip"])  # Support for other file types coming soon.
app.config["SUPPORTED_LANGUAGES"] = set(["java", "python"])

# Helper methods
def valid_file(filename):
    return "." in filename and filename.rsplit(".", 1)[1] in app.config["ALLOWED_EXTENSIONS"]


def filetype(filename):
    return filename.rsplit(".", 1)[1]


# Controllers
@app.route("/", methods=["GET", "POST"])
@app.route("/<language>", methods=["GET", "POST"])
def upload(language="python"):
Example #17
0
import os.path
import db
from flask import Flask, redirect, request, render_template, url_for, send_from_directory, session
from werkzeug import secure_filename

app = Flask(__name__)
app.secret_key = "dsjhgaslkdjfd"
app.config["DEFAULT_FILE_STORAGE"] = "filesystem"
app.config["FILE_SYSTEM_STORAGE_FILE_VIEW"] = "static"
app.config["UPLOAD_FOLDER"] = "uploads/"
app.config["ALLOWED_EXTENSIONS"] = set(["txt", "mp3", "bmp", "jpg", "jpeg"])


@app.route("/")
def index():
    if "username" in session:
        return redirect(url_for("dashboard"))
    else:
        return render_template("index.html")


@app.route("/dashboard")
def dashboard():
    if "username" in session:
        return render_template("dashboard.html", uploads=db.getUploads(session["username"]))
    else:
        return redirect(url_for("index"))


@app.route("/signup", methods=["GET", "POST"])
def signup():
Example #18
0
# 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, Markup
from werkzeug import secure_filename
import subprocess
import cv2

# Initialize the Flask application
app = Flask(__name__)

# Size limit
app.config["MAX_CONTENT_LENGTH"] = 4 * 1024 * 1024
# This is the path to the upload directory
app.config["UPLOAD_FOLDER"] = "uploads/"
# These are the extension that we are accepting to be uploaded
app.config["ALLOWED_EXTENSIONS"] = set(["png", "jpg", "jpeg", "bmp"])
# Result folder
app.config["OUTPUT_FOLDER"] = "output/"


def adaptive_resize(filename, max_size=640):
    img = cv2.imread(filename, 1)
    h, w, _ = img.shape
    ratio1 = float(max_size) / h
    ratio2 = float(max_size) / w
    ratio = min(ratio1, ratio2)
    if ratio >= 1:
        return
    img = cv2.resize(img, (int(ratio * w), int(ratio * h)))
    cv2.imwrite(filename, img)
Example #19
0
from flask import Flask, render_template, request
import subprocess
import uuid
import os

app = Flask(__name__)

cmd1 = ["ansible-inventory-grapher", "-i", "hosts", "<hostname>"]
cmd2 = ["dot", "-Tpng"]
app.config["UPLOAD_FOLDER"] = "/tmp/"
app.config["ALLOWED_EXTENSIONS"] = set([".tar.gz"])


def allowed_file(filename):
    return ".tar.gz" in filename


@app.route("/", methods=["GET", "POST"])
def index(hostname=None):
    if request.method == "GET":
        return render_template("index.html")
    elif request.method == "POST":
        print 1
        # file = request.files['tar']
        print 2
        # logging.debug('uploading file ' + file.filename)
        print 3
        # content = file.read()
        print 4
        # print content
        print 5
Example #20
0
import os
from flask import Flask
from hashids import Hashids
from flask_sqlalchemy import SQLAlchemy

basedir = os.path.abspath(os.path.dirname(__file__))
app = Flask(__name__)
app.config["DEBUG"] = True
app.config["SECRET_KEY"] = "secret"
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///" + os.path.join(os.getcwd(), "onsmash.db")
app.config["UPLOAD_FOLDER"] = os.path.join(os.getcwd(), "THUMBNAILS")
app.config["ALLOWED_EXTENSIONS"] = ["png", "jpg", "jpeg", "gif"]

db = SQLAlchemy(app)
hashids = Hashids(salt=app.config["SECRET_KEY"])

import views
import models
Example #21
0
import os
from flask import Flask, request, render_template, redirect, url_for, send_from_directory
import os.path
from werkzeug import secure_filename
import random

app = Flask(__name__)
app.config["UPLOAD_FOLDER"] = "uploads/"
app.config["ALLOWED_EXTENSIONS"] = set(["mpeg", "ogg", "mp3", "wav"])


def allowed_file(filename):
    return "." in filename and filename.rsplit(".", 1)[1] in app.config["ALLOWED_EXTENSIONS"]


@app.route("/")
@app.route("/Library", methods=["GET", "POST"])
def library():
    f = open("Public", "r")
    f2 = f.read()
    f.close()
    try:
        f4 = request.url
        f5 = f4.split("?")
        f6 = f5[1].split("&user&password")
        f = open(f6[0], "r")
        f7 = f.read()
        f8 = f7.split("<!>")
        f.close()
        if f6[1] == f8[2]:
            f = open(f6[0] + ".lib", "r")
Example #22
0
    return utils.to_json({"Update": True})


@app.route("/images/<path:path>")
def images(path):
    return send_from_directory("images", path)


### upload file


# This is the path to the upload directory
app.config["UPLOAD_FOLDER"] = "images/"
# These are the extension that we are accepting to be uploaded
app.config["ALLOWED_EXTENSIONS"] = set(["png"])

# 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"]


@app.route("/upload", methods=["POST"])
def upload():
    print "uploading... %s" % request.files["file"]
    # Get the name of the uploaded file
    file = request.files["file"]
    # Check if the file is one of the allowed types/extensions
    if file and allowed_file(file.filename):
        # Make the filename safe, remove unsupported chars
        filename = secure_filename(file.filename)
Example #23
0
    DATABASE = "sqliteext:///%s" % os.path.join(APP_DIR, "permanote.db")

application = Flask(__name__)
application.config.from_object(__name__)

# FlaskDB is a wrapper for a peewee database that sets up pre/post-request
# hooks for managing database connections.
flask_db = FlaskDB(application)

# The `database` is the actual peewee database, as opposed to flask_db which is
# the wrapper.
database = flask_db.database

# Upload folder and file allowed extensions
if os.getenv("SANDSTORM"):
    application.config["UPLOAD_FOLDER"] = "/var/uploads"
    application.config["DEBUG"] = False
else:
    application.config["UPLOAD_FOLDER"] = "%s/uploads" % os.path.join(APP_DIR)
    application.config["DEBUG"] = True

# file types allowed for upload
application.config["ALLOWED_EXTENSIONS"] = set(["jpg", "jpeg", "png", "gif", "webp"])

# This is used by micawber, which will attempt to generate rich media
# embedded objects with maxwidth=800.
application.config["SITE_WIDTH"] = 800

# The secret key is used internally by Flask to encrypt session data stored
# in cookies. Make this unique for your app.
application.config["SECRET_KEY"] = "asdfkj23kjdflkj23lkjs"
Example #24
0
templateData = {
    "consoledata": "Nothing yet" + "\n",
    "baseimagedata": "BaseStation offline" + "\n",
    "flashstarted": "False",
}

slotnum = 1
imagepath = "uploads/"

# Initialize the Flask application
app = Flask(__name__)
app.debug = True

# Code uploading
app.config["UPLOAD_FOLDER"] = "uploads/"
app.config["ALLOWED_EXTENSIONS"] = set(["xml"])

# Packet sniffing
app.config["SECRET_KEY"] = "secret!"
socketio = SocketIO(app)
listenrequest = False
flashresponse = False
ackrequired = False
checksumvalid = True
mqttc = mqtt.Client()

# Database initialisation
file_status = os.path.isfile("gateway.db")

if file_status == False:
    conn = sqlite3.connect("gateway.db")
Example #25
0
from oauth2client.client import FlowExchangeError
from flask import session as login_session
from flask import make_response
import random
import string
import httplib2
import json
import requests


app = Flask(__name__)

# Path to the images directory
app.config["UPLOAD_FOLDER"] = "uploads/"
# These are the extension that we are accepting to be uploaded
app.config["ALLOWED_EXTENSIONS"] = set(["jpg", "jpeg", "gif"])

# Create session and connect to DB
engine = create_engine("sqlite:///categoryitems.db")
Base.metadata.bind = engine
DBSession = sessionmaker(bind=engine)
session = DBSession()


# API Endpoints
@app.route("/catalog.xml")
def catagoryXML():
    user_pages = []
    users = session.query(User).all()
    for user in users:
        user_pages.append([user.id, user.name, user.email, user.picture])
Example #26
0
from flask import Flask
import sys
from reports.publications.articles import report_per_year as report_year_articles
from reports.publications.videos import report_per_year as report_year_videos
from reports.top_owner import report_per_period as report_top_owner
from reports.number_views import report_per_period as report_number_views
from reports.infographic_publications import report_per_period as report_infographic_publications
from reports.top_report import report_per_period as report_top
from reports.factor_report import report_per_period as report_factors
from max_dev import root_path

from uploadExcel import upload_api

app = Flask(__name__)
app.config["UPLOAD_FOLDER"] = "uploads/"
app.config["ALLOWED_EXTENSIONS"] = set(["xlsx", "xlsm"])
app.register_blueprint(upload_api)

root_path.set_root_path_from(__file__)


@app.route("/")
def home():
    return app.send_static_file("selector_report.html")


@app.route("/<path:path>")
def selector(path):
    print path
    return app.send_static_file(path)
Example #27
0
from pyqrcode import create as create_qrcode
from os import listdir, makedirs, remove
from os.path import isdir, isfile, join
from json import dumps, loads
from random import randint
from re import sub
from config import host_address as host, host_port as port, public_ip as ip
from config import admin_credentials
from sys import argv

argv.pop(0)

app = Flask(__name__)

app.config["UPLOAD_FOLDER"] = "uploads/"
app.config["ALLOWED_EXTENSIONS"] = ["pdf"]


@app.route("/")
def homepage():
    AUTHORS = []
    CATEGORIES = []
    LANGUAGES = []
    NUM_BOOKS = len(listdir("books"))
    for book in listdir("books"):
        book_data = loads(open("books/%s/data.json" % book, "r").read())
        for author in book_data["authors"]:
            author = author.title()
            if author not in AUTHORS:
                AUTHORS.append(author)
        for category in book_data["categories"]:
Example #28
0
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config.from_object("config")

db = SQLAlchemy(app)

ALLOWED_EXTENSIONS = set(["png", "jpg", "jpeg", "gif", "bmp"])
UPLOAD_FOLDER = "/static/uploads/"
app.config["UPLOAD_FOLDER"] = UPLOAD_FOLDER
app.config["ALLOWED_EXTENSIONS"] = ALLOWED_EXTENSIONS
app.config["MAX_CONTENT_LENGTH"] = 16 * 1024 * 1024

# important, for some reason, that this stay down here
from app import views, models


import logging
from logging.handlers import RotatingFileHandler

file_handler = RotatingFileHandler("tmp/website.log", "a", 1 * 1024 * 1024, 10)
file_handler.setFormatter(logging.Formatter("%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]"))
app.logger.setLevel(logging.INFO)
file_handler.setLevel(logging.INFO)
app.logger.addHandler(file_handler)
app.logger.info("website startup")
Example #29
0
import sys

sys.path.insert(0, "./src")
from producer import serverEntry
import multiprocessing as mp
import os
from flask import Flask, render_template, request, redirect, url_for, Response, stream_with_context
from werkzeug import secure_filename

app = Flask(__name__)

# The file the user uploads will get saved here so we can access it
app.config["UPLOAD_FOLDER"] = "static/query"
app.config["DATABASE"] = "static/video"
app.config["ALLOWED_EXTENSIONS"] = set(["mp4"])


# Home page:
#     User can: upload a video and select a threshold,
#               they also have access to the about and help pages
@app.route("/")
def index():
    return render_template("home.html")


# Purpose: process the file upload and then redirect the user to the results page
@app.route("/upload/", methods=["POST", "GET"])
def upload():
    # Get the name of the uploaded file
    file = request.files["file"]