Example #1
0
File: app.py Project: steinar/eloi
from flask import Flask
from flask.ext.uploads import UploadSet, IMAGES, configure_uploads
from booking import settings

app = Flask(__name__)


# Images
app.config["UPLOADS_DEFAULT_DEST"] = settings.UPLOADS_DEFAULT_DEST
app.config["UPLOADS_DEFAULT_URL"] = settings.UPLOADS_DEFAULT_URL
images = UploadSet("images", IMAGES)
configure_uploads(app, (images,))
Example #2
0
login = LoginManager()
login.init_app(app, add_context_processor=True)
login.login_view = "login"

app.jinja_env.filters["nl2br"] = nl2br
app.jinja_env.filters["none2blank"] = none2blank
app.jinja_env.filters["rough_format"] = rough_format
app.jinja_env.globals["hasattr"] = hasattr
app.jinja_env.globals["len"] = len
app.jinja_env.globals["demo"] = app.config["DEMO"]
app.jinja_env.globals["BASE_URL"] = app.config["BASE_URL"]

# uploads
current_path = os.path.dirname(os.path.abspath(__file__))
app.config["UPLOADS_DEFAULT_DEST"] = os.path.join(current_path, os.path.join("static", "uploads"))
app.config["UPLOADS_DEFAULT_URL"] = "/static/uploads/"

book_staging_upload_set = uploads.UploadSet(
    "bookstaging", extensions=app.config["EBOOK_EXTENSIONS"], default_dest=lambda x: app.config["LIBRARY_STAGING_PATH"]
)
book_upload_set = uploads.UploadSet(
    "books", extensions=app.config["EBOOK_EXTENSIONS"], default_dest=lambda x: app.config["LIBRARY_PATH"]
)
cover_upload_set = uploads.UploadSet("covers", uploads.IMAGES)
tmp_cover_upload_set = uploads.UploadSet("tmpcovers", uploads.IMAGES)

uploads.configure_uploads(app, (book_upload_set, cover_upload_set, book_staging_upload_set, tmp_cover_upload_set))


def content_type(content_type):
    """Adds Content-type header to requests"""