get upload skel working

main
lza_menace 2 years ago
parent 24cfc1aa8c
commit 328f710734

@ -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

@ -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'

@ -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")
await flash('Uploaded successfully!', 'is-success')
return redirect(url_for('manage.index'))
return render_template('upload.html')

@ -8,7 +8,6 @@
{% endif %}
{% endwith %}
<!-- <script src="/static/js/vendor/metamask-onboarding-1.0.1.bundle.js"></script> -->
<script>
window.addEventListener('DOMContentLoaded', () => {
const connectButton = document.getElementById('connectWallet');

@ -1,4 +1,27 @@
{% extends 'base.html' %}
{% block content %}
<p>upload</p>
{% endblock %}
<form method="post" enctype=multipart/form-data class="form-horizontal">
<div class="field">
<label class="label">Title</label>
<div class="control">
<input class="input" type="text" placeholder="So there I was..." name="title">
</div>
</div>
<div class="field">
<label class="label">Text</label>
<div class="control">
<textarea class="textarea" placeholder="balls deep in a jar of mayonnaise" name="text"></textarea>
</div>
</div>
<div class="field">
<label class="label">Upload</label>
<input type="file" name="file" multiple>
</div>
<div class="field is-grouped">
<div class="control">
<button class="button is-link">Submit</button>
</div>
</div>
</form>
{% endblock %}

Loading…
Cancel
Save