upload form zdaj prinese FileStorage objekt
parent
d07c5c2597
commit
f8bae1331a
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
</body>
|
</body>
|
||||||
<form method="post" enctype="multipart/form-data" action="localhost:5000/upload/uploader">
|
<form id="form" method="post" enctype="multipart/form-data" action="/upload/uploader">
|
||||||
<div class="drop-zone">
|
<div class="drop-zone">
|
||||||
<span class="drop-zone__prompt">Drop file here or click to upload</span>
|
<span class="drop-zone__prompt">Drop file here or click to upload</span>
|
||||||
<input type="file" name="file" class="drop-zone__input">
|
<input type="file" name="file" class="drop-zone__input">
|
||||||
|
@ -42,6 +42,8 @@
|
||||||
|
|
||||||
if (e.dataTransfer.files.length) {
|
if (e.dataTransfer.files.length) {
|
||||||
inputElement.files = e.dataTransfer.files;
|
inputElement.files = e.dataTransfer.files;
|
||||||
|
console.log("oddajam form", e);
|
||||||
|
document.getElementById("form").submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
dropZoneElement.classList.remove("drop-zone--over");
|
dropZoneElement.classList.remove("drop-zone--over");
|
||||||
|
|
15
upload.py
15
upload.py
|
@ -1,3 +1,4 @@
|
||||||
|
from email import message
|
||||||
from flask import (
|
from flask import (
|
||||||
Blueprint, flash, g, redirect, render_template, request, session, url_for
|
Blueprint, flash, g, redirect, render_template, request, session, url_for
|
||||||
)
|
)
|
||||||
|
@ -16,6 +17,11 @@ engine = create_engine(CONFIG['DB_CONNECTION'])
|
||||||
dbsessionmaker = sessionmaker(bind=engine)
|
dbsessionmaker = sessionmaker(bind=engine)
|
||||||
dbsession = dbsessionmaker()
|
dbsession = dbsessionmaker()
|
||||||
|
|
||||||
|
|
||||||
|
nc = nextcloud_client.Client('https://obzorje.kompot.si')
|
||||||
|
nc.login('gia', 'gia0000!')
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/", methods=("GET", "POST"))
|
@bp.route("/", methods=("GET", "POST"))
|
||||||
def index():
|
def index():
|
||||||
return render_template("menu/upload.html")
|
return render_template("menu/upload.html")
|
||||||
|
@ -24,16 +30,19 @@ def index():
|
||||||
@bp.route('/uploader', methods = ['GET', 'POST'])
|
@bp.route('/uploader', methods = ['GET', 'POST'])
|
||||||
def upload_file():
|
def upload_file():
|
||||||
print("heyy")
|
print("heyy")
|
||||||
|
message = ""
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
#flask gets the file
|
#flask gets the file
|
||||||
upload = request.files["file"]
|
upload = request.files #???
|
||||||
print("hello")
|
|
||||||
|
|
||||||
#upload to nc
|
#upload to nc
|
||||||
|
#nc.put_file('testdir/remotefile.txt', 'localfile.txt') #not sure kako bi to
|
||||||
#get public link
|
#get public link
|
||||||
|
#link = nc.share_file_with_link('testdir/remotefile.txt')
|
||||||
|
|
||||||
#update db
|
#update db
|
||||||
#predpostavlja title, ir, owner_id, item_location
|
#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.add(card)
|
||||||
#dbsession.commit()
|
#dbsession.commit()
|
||||||
|
return render_template("menu/upload.html", message=message)
|
Loading…
Reference in New Issue