From f8bae1331a5e62bf38396737cf96203da70d22e7 Mon Sep 17 00:00:00 2001 From: Kostanjevec Date: Sun, 5 Jun 2022 21:18:24 +0200 Subject: [PATCH] upload form zdaj prinese FileStorage objekt --- templates/menu/upload.html | 4 +++- upload.py | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/templates/menu/upload.html b/templates/menu/upload.html index b417223..a95fdd6 100644 --- a/templates/menu/upload.html +++ b/templates/menu/upload.html @@ -10,7 +10,7 @@ {% block content %} -
+
Drop file here or click to upload @@ -42,6 +42,8 @@ if (e.dataTransfer.files.length) { inputElement.files = e.dataTransfer.files; + console.log("oddajam form", e); + document.getElementById("form").submit(); } dropZoneElement.classList.remove("drop-zone--over"); diff --git a/upload.py b/upload.py index 43d7b8d..bcecba8 100644 --- a/upload.py +++ b/upload.py @@ -1,3 +1,4 @@ +from email import message from flask import ( Blueprint, flash, g, redirect, render_template, request, session, url_for ) @@ -16,6 +17,11 @@ engine = create_engine(CONFIG['DB_CONNECTION']) dbsessionmaker = sessionmaker(bind=engine) dbsession = dbsessionmaker() + +nc = nextcloud_client.Client('https://obzorje.kompot.si') +nc.login('gia', 'gia0000!') + + @bp.route("/", methods=("GET", "POST")) def index(): return render_template("menu/upload.html") @@ -24,16 +30,19 @@ def index(): @bp.route('/uploader', methods = ['GET', 'POST']) def upload_file(): print("heyy") + message = "" if request.method == 'POST': #flask gets the file - upload = request.files["file"] - print("hello") - + upload = request.files #??? + #upload to nc + #nc.put_file('testdir/remotefile.txt', 'localfile.txt') #not sure kako bi to #get public link + #link = nc.share_file_with_link('testdir/remotefile.txt') #update db #predpostavlja title, ir, owner_id, item_location - #card = Card(title=name, interest_rate=-1.0, owner_id=1, item_location=public_link) + #card = Card(title=name, interest_rate=-1.0, owner_id=1, item_location=link, ) #dbsession.add(card) #dbsession.commit() + return render_template("menu/upload.html", message=message) \ No newline at end of file