Fix "SERVE_DIR" config
This commit is contained in:
parent
aa0921aae6
commit
838637de55
2 changed files with 3 additions and 3 deletions
|
@ -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):
|
||||
|
|
2
setup.py
2
setup.py
|
@ -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)
|
||||
|
||||
|
|
Reference in a new issue