1
0
Fork 0

Fix "SERVE_DIR" config

This commit is contained in:
Derek Schmidt 2018-08-24 13:22:44 -07:00
parent aa0921aae6
commit 838637de55
Signed by: skeh
GPG key ID: 0F5D491793B4035A
2 changed files with 3 additions and 3 deletions

View file

@ -118,7 +118,7 @@ def newreferal():
@login_required
def browse(path = None):
# Search for files in path
searchpath = os.path.join('files', path) if path is not None else 'files'
searchpath = os.path.join(app.config['SERVE_DIR'], path) if path is not None else app.config['SERVE_DIR']
# 404 if no such path exists
if not os.path.exists(searchpath):
@ -144,7 +144,7 @@ def browse(path = None):
@app.route('/files/<path:path>')
@login_required
def files(path):
return send_from_directory('files', path)
return send_from_directory(app.config['SERVE_DIR'], path)
@app.errorhandler(404)
def page_not_found(e):

View file

@ -9,7 +9,7 @@ import click
@click.option('--secret', help="Secret key to use. A random hex string will be generated if not provided")
@click.option('--db', 'connection', help="Database connection string. Defaults to \"sqlite:///test.db\"")
def main(serve_dir, secret=None, connection=None):
config = {"serve_dir": serve_dir, "SECRET_KEY": secret or secrets.token_hex(), "SQLALCHEMY_DATABASE_URI": connection or 'sqlite:///test.db'}
config = {"SERVE_DIR": serve_dir, "SECRET_KEY": secret or secrets.token_hex(), "SQLALCHEMY_DATABASE_URI": connection or 'sqlite:///test.db'}
with open('config.json', 'w') as f:
json.dump(config, f, indent=2)