Browse Source

Change archive listing to return JSON

main
Luke Murphy 5 years ago
parent
commit
83018a963f
No known key found for this signature in database GPG Key ID: 5E2EF5A63E3718CC
  1. 9
      voicegardens/server.py

9
voicegardens/server.py

@ -3,7 +3,7 @@
import os.path import os.path
from pathlib import Path from pathlib import Path
from flask import Flask, render_template, request, send_from_directory from flask import Flask, render_template, request, send_from_directory, jsonify
from flask_cors import CORS from flask_cors import CORS
from werkzeug.utils import secure_filename from werkzeug.utils import secure_filename
@ -58,5 +58,8 @@ def uploaded_file(filename):
def archive(): def archive():
"""Serve the archive listing.""" """Serve the archive listing."""
listing = os.listdir(UPLOAD_DIRECTORY) listing = os.listdir(UPLOAD_DIRECTORY)
files = filter(lambda f: f.endswith(".wav"), listing) filenames = filter(lambda f: f.endswith(".wav"), listing)
return render_template("archive.html", files=files) return jsonify([
"{}{}".format(request.url_root, filename)
for filename in filenames
])

Loading…
Cancel
Save