new route to list files in a share. TODO: use for split upload to check existing splits

This commit is contained in:
Ville Rantanen
2018-03-02 15:37:37 +02:00
parent 9e4b2892d5
commit cd76452779
2 changed files with 57 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ from flask import Flask, render_template, jsonify, current_app, Response, \
redirect, url_for, request, g, session, send_file, send_from_directory
from werkzeug.utils import secure_filename
import zipfile
import urllib
from multiprocessing import Process
from revprox import ReverseProxied
from utils.utils import *
@@ -169,6 +170,22 @@ def send(name):
return share
return render_template('send.html',name=name)
@app.route('/files/<name>/<token>', methods=['GET'])
def list_files(name, token):
(ok,share) = get_share(name, token = token)
if not ok:
return share
files = []
for file in sorted(os.listdir(share['path'])):
fp = os.path.join(share['path'],file)
if os.path.isdir(fp):
continue
if file.startswith("."):
continue
files.append(urllib.parse.quote_plus(file))
files.append("")
return "\n".join(files), 200
@app.route('/list/<name>/<token>', methods=['GET'])
@app.route('/list/<name>', methods=['GET'])
def list_view(name, token = None):