aboutsummaryrefslogtreecommitdiff
path: root/src/pydrilla
diff options
context:
space:
mode:
Diffstat (limited to 'src/pydrilla')
-rw-r--r--src/pydrilla/pydrilla.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/pydrilla/pydrilla.py b/src/pydrilla/pydrilla.py
index af4ff1c..b0a5974 100644
--- a/src/pydrilla/pydrilla.py
+++ b/src/pydrilla/pydrilla.py
@@ -24,7 +24,8 @@
# file's license. Although I request that you do not make use this code
# in a proprietary program, I am not going to enforce this in court.
-from flask import Flask, Blueprint, current_app, url_for, abort, request
+from flask import Flask, Blueprint, current_app, url_for, abort, request, \
+ redirect
from jinja2 import Environment, PackageLoader
import re
#from hashlib import sha256
@@ -591,6 +592,8 @@ def create_app(config_path=(here / 'config.json'), flask_config={}):
raise ValueError(_('config_key_absent_{}').format(key))
app._pydrilla_static_resource_uri = config['static_resource_uri']
+ if app._pydrilla_static_resource_uri[-1] != '/':
+ app._pydrilla_static_resource_uri += '/'
app._pydrilla_hydrilla_sources_uri = config['hydrilla_sources_uri']
app._pydrilla_werror = config.get('werror', False)
if 'hydrilla_parent' in config:
@@ -698,3 +701,12 @@ def query():
url = request.args['url']
return json.dumps(content().query(url))
+
+@bp.route('/sources/<string:identifier>/<path:path>')
+def get_file(identifier, path):
+ if identifier not in content().indexes:
+ abort(404)
+
+ new_uri = f'{current_app._pydrilla_static_resource_uri}{identifier}/{path}'
+
+ return redirect(new_uri, code=301)