Skip to content

Commit

Permalink
Autoformat with black
Browse files Browse the repository at this point in the history
  • Loading branch information
demccormack committed Oct 14, 2023
1 parent b2e11b3 commit f2227df
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
5 changes: 5 additions & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
black==23.9.1
click==8.1.3
Flask==2.2.2
Flask-Cors==3.0.10
gunicorn==20.1.0
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.1
mypy-extensions==1.0.0
packaging==23.2
pathspec==0.11.2
platformdirs==3.11.0
six==1.16.0
Werkzeug==2.2.2
23 changes: 16 additions & 7 deletions backend/src/app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=missing-module-docstring
import sys
from os import environ, listdir, path
from urllib.parse import quote, unquote
Expand All @@ -7,27 +8,35 @@

app = Flask(__name__)

CORS(app, origins=environ['CORS_ORIGINS'].split())
CORS(app, origins=environ["CORS_ORIGINS"].split())

mediaRoot = environ['MEDIA']
mediaRoot = environ["MEDIA"]

@app.route('/', methods=['GET'])

@app.route("/", methods=["GET"])
def get_films():
dir = unquote(request.args.get('dir'))
dir = unquote(request.args.get("dir"))
dirPath = path.join(mediaRoot, dir)
return jsonify(filmTree(dirPath))


def filmTree(dir):
ls = sorted(listdir(dir))
result = []
for item in ls:
fullPath = path.join(dir, item)
url = quote(fullPath[len(mediaRoot):])
result.append({'name': item, 'type': 'directory' if path.isdir(fullPath) else 'file', 'url': url})
url = quote(fullPath[len(mediaRoot) :])
result.append(
{
"name": item,
"type": "directory" if path.isdir(fullPath) else "file",
"url": url,
}
)
return result


if __name__ == '__main__':
if __name__ == "__main__":
cli_args = sys.argv[1:]

# If the IP and port are supplied as arguments, use them.
Expand Down

0 comments on commit f2227df

Please sign in to comment.