Example #1
0
File: app.py Project: JiscPER/store
import os, requests, json, uuid, shutil

from flask import Flask, request, send_file, abort, make_response, logging

from logging import Formatter
from logging.handlers import RotatingFileHandler


app = Flask(__name__)
app.config["HOST"] = "localhost"
app.config["DEBUG"] = False
app.config["PORT"] = 5999
app.config["THREADED"] = True
app.config["STORAGE_FOLDER"] = "/home/mark/store"

file_handler = RotatingFileHandler("/home/mark/jperstorelog", maxBytes=1000000000, backupCount=5)
file_handler.setLevel(logging.DEBUG)
file_handler.setFormatter(
    Formatter("%(asctime)s %(levelname)s: %(message)s " "[in %(pathname)s:%(lineno)d %(module)s %(funcName)s]")
)
app.logger.addHandler(file_handler)


@app.route("/")
@app.route("/<path:path>", methods=["GET", "POST", "PUT", "DELETE"])
def storage(path=""):
    if ".." in path or path.startswith("/"):
        abort(400)
    dir = app.config["STORAGE_FOLDER"] + "/" + path
    if path == "":
        listing = os.listdir(dir)
Example #2
0
from views.height import bp as height
from views.igc import bp as igc
from views.search import bp as search
from views.settings import bp as settings
from views.tasks import bp as tasks
from views.waypoints import bp as waypoints

APP_FOLDER = os.path.abspath(os.path.join(__file__, "..", ".."))
STORAGE_FOLDER = os.path.join(APP_FOLDER, "storage")

AVAILABLE_LOCALES = ["en", "de", "cs"]

app = Flask(__name__, static_folder=os.path.join(APP_FOLDER, "web"), static_url_path="")

app.config["APP_FOLDER"] = APP_FOLDER
app.config["STORAGE_FOLDER"] = STORAGE_FOLDER
app.config["UPLOAD_FOLDER"] = os.path.join(STORAGE_FOLDER, "temp")
app.config["USERS_FOLDER"] = os.path.join(STORAGE_FOLDER, "users")

babel = Babel(app)


@babel.localeselector
def get_locale():
    preferred = map(lambda x: x.replace("-", "_"), request.accept_languages.values())
    return negotiate_locale(preferred, AVAILABLE_LOCALES)


@app.context_processor
def inject_get_locale():
    return dict(get_locale=get_locale)