diff --git a/flipbook/config.py b/flipbook/config.py index 180ccf6..9559dc3 100644 --- a/flipbook/config.py +++ b/flipbook/config.py @@ -22,18 +22,7 @@ CONTRACT_ADDRESS = getenv('CONTRACT_ADDRESS') MAX_CONTENT_LENGTH = 50 * 1024 * 1024 ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'svg'} UPLOADS_PATH = getenv('UPLOADS_PATH', 'data/uploads') -SESSION_LIFETIME = getenv('SESSION_LIFETIME', 30) - -# Database -DB_HOST = getenv('DB_HOST', 'localhost') -DB_PORT = getenv('DB_PORT', 5432) -DB_NAME = getenv('DB_NAME', 'flipbook') -DB_USER = getenv('DB_USER', 'flipbook') -DB_PASS = getenv('DB_PASS') - -# Redis -REDIS_HOST = getenv('REDIS_HOST', 'localhost') -REDIS_PORT = getenv('REDIS_PORT', 6379) +SESSION_LIFETIME = getenv('SESSION_LIFETIME', 60 * 60 * 24) # Development TEMPLATES_AUTO_RELOAD = True diff --git a/flipbook/factory.py b/flipbook/factory.py index fa765e7..3c94365 100644 --- a/flipbook/factory.py +++ b/flipbook/factory.py @@ -15,7 +15,8 @@ async def setup_db(app: Quart): def create_app(): app = Quart(__name__) app.config.from_envvar('FLASK_SECRETS') - login_manager = LoginManager(app) + login_manager = LoginManager() + login_manager.init_app(app) login_manager.login_view = 'meta.index' login_manager.logout_view = 'meta.logout' diff --git a/flipbook/routes/manage.py b/flipbook/routes/manage.py index 334ffb8..b29fe06 100644 --- a/flipbook/routes/manage.py +++ b/flipbook/routes/manage.py @@ -5,6 +5,7 @@ from quart import Blueprint, render_template, request, redirect, url_for, flash, from flask_login import login_required, current_user from werkzeug.utils import secure_filename +from flipbook.models import Upload from flipbook.helpers import allowed_file from flipbook import config @@ -19,22 +20,22 @@ async def index(): @bp.route('/upload', methods=['GET', 'POST']) @login_required async def upload(): - if request.method == "POST": - data = await request.get_data() - print(data) - post_title = request.form.get("title") - if "file" not in request.files: - await flash("You didn't upload a caliente meme, bro! You're fuckin up!", "is-danger") + if request.method == 'POST': + data = await request.form + file = await request.files + post_title = data['title'] + if 'file' not in request.files: + await flash('You didn\'t upload a caliente meme, bro! You\'re fuckin up!', 'is-danger') return await redirect(request.url) - file = request.files["file"] - if file.filename == "": - await flash("You didn't upload a caliente meme, bro! You're fuckin up!", "is-danger") + file = request.files['file'] + if file.filename == '': + await flash('You didn\'t upload a caliente meme, bro! You\'re fuckin up!', 'is-danger') return await redirect(request.url) - if post_title == "": - await flash("You didn't give your meme a spicy title, bro! You're fuckin up!", "is-danger") + if post_title == '': + await flash('You didn\'t give your meme a spicy title, bro! You\'re fuckin up!', 'is-danger') return await redirect(request.url) if file and allowed_file(file.filename): - filename = "{}-{}".format( + filename = '{}-{}'.format( token_urlsafe(12), secure_filename(file.filename) ) @@ -43,11 +44,11 @@ async def upload(): token_id=0, title=post_title, image_name=filename, - text=request.form.get('text', ''), + text=data['text'], wallet=current_user, ) upload.save() # upload.save_thumbnail() - await flash("Uploaded successfully!", "is-success") - return redirect(url_for("manage.index")) - return render_template("upload.html") \ No newline at end of file + await flash('Uploaded successfully!', 'is-success') + return redirect(url_for('manage.index')) + return render_template('upload.html') \ No newline at end of file diff --git a/flipbook/templates/includes/scripts.html b/flipbook/templates/includes/scripts.html index a8f9b8f..a95c883 100644 --- a/flipbook/templates/includes/scripts.html +++ b/flipbook/templates/includes/scripts.html @@ -8,7 +8,6 @@ {% endif %} {% endwith %} -