Compare commits

...

4 Commits

Author SHA1 Message Date
Kostanjevec 702b82fc3e vzpostavil upload na nextcloud 2022-06-08 19:51:55 +02:00
Kostanjevec 42743e00c2 share sem dal ven iz rate forma, ni pomagalo za 405 2022-06-08 18:40:29 +02:00
Kostanjevec 3de2f056ce pages get userinfo from session 2022-06-07 18:58:57 +02:00
Kostanjevec 91e0d17385 added a link to menu in appname 2022-06-07 18:57:48 +02:00
3 changed files with 28 additions and 13 deletions

View File

@ -1,8 +1,8 @@
<!doctype html>
<title>{% block title %}{% endblock %} - contentmatcher</title>
<title>{% block title %}{% endblock %} - contentmatcher </title>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
<nav>
<h1>contentmatcher</h1>
<h1><a href="{{ url_for('menu.index') }}">contentmatcher</a></h1>
<ul>
{% if username %}
<li><span>{{username}}</span>

View File

@ -14,8 +14,8 @@
<button input type="submit" name="rate" data-cardtitle=card[title] value="Yes" accesskey="1">Yes</button> <!--ti keyi so alt+shit+key...-->
<button input type="submit" name="rate" value="Maybe" accesskey="2">Maybe</button>
<button input type="submit" name="rate" value="No" accesskey="3">No</button>
<button input type="submit" name="share" value="share">Share</button>
</form>
<button input type="submit" name="share" value="share">Share</button>
</article>
<script type="text/javascript" src="{{ url_for('static', filename='js/pdf.js') }}"></script>

View File

@ -1,7 +1,9 @@
from email import message
import tempfile
import os
from flask import (
Blueprint, flash, g, redirect, render_template, request, session, url_for
)
from werkzeug.utils import secure_filename
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from auth import login_required
@ -11,6 +13,7 @@ from create_db import User, Card
import nextcloud_client
bp = Blueprint('upload', __name__, url_prefix='/upload')
engine = create_engine(CONFIG['DB_CONNECTION'])
@ -22,27 +25,39 @@ nc = nextcloud_client.Client('https://obzorje.kompot.si')
nc.login('gia', 'gia0000!')
@bp.route("/", methods=("GET", "POST"))
@bp.route("/", methods=["GET", "POST"])
def index():
return render_template("menu/upload.html")
username = session["username"]
return render_template("menu/upload.html", username=username)
@bp.route('/uploader', methods = ['GET', 'POST'])
@bp.route('/uploader', methods = ('GET', 'POST'))
def upload_file():
print("heyy")
user_id = session["user_id"]
username = session["username"]
message = ""
if request.method == 'POST':
#flask gets the file
upload = request.files #???
upload = request.files["file"]
filename = secure_filename(upload.filename)
script_path = os.path.dirname(os.path.abspath(__file__))
temp_path = script_path + "\\temp\\"
#upload to nc
#nc.put_file('testdir/remotefile.txt', 'localfile.txt') #not sure kako bi to
with tempfile.NamedTemporaryFile(dir=temp_path, delete=False) as fp:
fp.write(upload.stream.read())
path = fp.name
fp.close()
nc.put_file("/GIA CLOUD/" + filename, "temp\\" + path.split("\\")[-1])
os.remove(fp.name)
#get public link
#link = nc.share_file_with_link('testdir/remotefile.txt')
link = nc.share_file_with_link("/GIA CLOUD/" + filename)
print(link)
#update db
#predpostavlja title, ir, owner_id, item_location
#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)
return render_template("menu/upload.html", message=message, user_id=user_id, username=username)