Created
March 12, 2019 12:42
-
-
Save Akronix/eeed0cecdce456c4f4da8f7eab8772af to your computer and use it in GitHub Desktop.
Flask - Serve all dependencies from a local lib/ directory in development mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Serve lib/ folder only in development mode | |
@server_bp.route('/lib/<dep>', defaults={'path': ''}) | |
@server_bp.route('/lib/<path:path>/<dep>') | |
def serve_lib_in_dev(path, dep): | |
path = os.path.join('lib/', path) | |
dev = current_app.config["DEBUG"] | |
if dev: | |
return flask.send_from_directory(path, dep) | |
else: | |
print('Trying to retrieve a dependency from a local folder in production. Skipping.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment