From f8d3547599db5a3546e1622a18bc291334d5f763 Mon Sep 17 00:00:00 2001 From: Kostanjevec Date: Sun, 5 Jun 2022 18:53:31 +0200 Subject: [PATCH] =?UTF-8?q?za=C4=8Del=20delat=20upload,=20ampak=20=C5=A1e?= =?UTF-8?q?=20ni=20prav=20dale=C4=8D...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/menu/upload.html | 53 ++++++++++++++++++++++++++++++++++++++ upload.py | 39 ++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 templates/menu/upload.html create mode 100644 upload.py diff --git a/templates/menu/upload.html b/templates/menu/upload.html new file mode 100644 index 0000000..b417223 --- /dev/null +++ b/templates/menu/upload.html @@ -0,0 +1,53 @@ +{% extends 'base.html' %} + +{% block header %} + + Drag and Drop File Upload + + + +{% endblock %} + +{% block content %} + +
+
+ Drop file here or click to upload + + +
+
+ + + + +{% endblock %} \ No newline at end of file diff --git a/upload.py b/upload.py new file mode 100644 index 0000000..43d7b8d --- /dev/null +++ b/upload.py @@ -0,0 +1,39 @@ +from flask import ( + Blueprint, flash, g, redirect, render_template, request, session, url_for +) +from sqlalchemy import create_engine +from sqlalchemy.orm import sessionmaker +from auth import login_required + +from config import CONFIG +from create_db import User, Card + +import nextcloud_client + +bp = Blueprint('upload', __name__, url_prefix='/upload') + +engine = create_engine(CONFIG['DB_CONNECTION']) +dbsessionmaker = sessionmaker(bind=engine) +dbsession = dbsessionmaker() + +@bp.route("/", methods=("GET", "POST")) +def index(): + return render_template("menu/upload.html") + + +@bp.route('/uploader', methods = ['GET', 'POST']) +def upload_file(): + print("heyy") + if request.method == 'POST': + #flask gets the file + upload = request.files["file"] + print("hello") + + #upload to nc + #get public link + + #update db + #predpostavlja title, ir, owner_id, item_location + #card = Card(title=name, interest_rate=-1.0, owner_id=1, item_location=public_link) + #dbsession.add(card) + #dbsession.commit()