Compare commits
2 Commits
702b82fc3e
...
eee26a2b3b
Author | SHA1 | Date |
---|---|---|
Kostanjevec | eee26a2b3b | |
Kostanjevec | 3e7970c4f3 |
2
app.py
2
app.py
|
@ -47,7 +47,7 @@ def create_app(test_config=None):
|
||||||
|
|
||||||
|
|
||||||
#@login_required
|
#@login_required
|
||||||
@app.route('/deck/index', methods=("GET", "POST"))
|
@app.route('/deck/index', methods=["GET", "POST"])
|
||||||
def deck():
|
def deck():
|
||||||
if 'user_id' in session:
|
if 'user_id' in session:
|
||||||
user_id = session['user_id']
|
user_id = session['user_id']
|
||||||
|
|
19
upload.py
19
upload.py
|
@ -44,20 +44,21 @@ def upload_file():
|
||||||
script_path = os.path.dirname(os.path.abspath(__file__))
|
script_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
temp_path = script_path + "\\temp\\"
|
temp_path = script_path + "\\temp\\"
|
||||||
|
|
||||||
|
|
||||||
|
#a lot of stuff can wrong here and nobody may know
|
||||||
with tempfile.NamedTemporaryFile(dir=temp_path, delete=False) as fp:
|
with tempfile.NamedTemporaryFile(dir=temp_path, delete=False) as fp:
|
||||||
fp.write(upload.stream.read())
|
fp.write(upload.stream.read())
|
||||||
path = fp.name
|
path = fp.name
|
||||||
fp.close()
|
fp.close()
|
||||||
nc.put_file("/GIA CLOUD/" + filename, "temp\\" + path.split("\\")[-1])
|
nc.put_file("/GIA CLOUD/" + filename, "temp\\" + path.split("\\")[-1])
|
||||||
os.remove(fp.name)
|
os.remove(fp.name)
|
||||||
|
|
||||||
#get public link
|
#get public link
|
||||||
link = nc.share_file_with_link("/GIA CLOUD/" + filename)
|
public_link = nc.share_file_with_link("/GIA CLOUD/" + filename).get_link()+"/download/"+filename
|
||||||
print(link)
|
|
||||||
|
#add card
|
||||||
#update db
|
card = Card(title=filename, interest_rate=-1.0, owner_id=user_id, item_location=public_link, last_review=None)
|
||||||
#predpostavlja title, ir, owner_id, item_location
|
dbsession.add(card)
|
||||||
#card = Card(title=name, interest_rate=-1.0, owner_id=1, item_location=link, )
|
dbsession.commit()
|
||||||
#dbsession.add(card)
|
|
||||||
#dbsession.commit()
|
|
||||||
return render_template("menu/upload.html", message=message, user_id=user_id, username=username)
|
return render_template("menu/upload.html", message=message, user_id=user_id, username=username)
|
Loading…
Reference in New Issue