Reduce this to the simplest method that will work:
- Put static assets in the
static subfolder. - The "Remaining flask" setting is set by default, do not give it
static_url_path . - Access to static content using pre-configured
/static/ to check file operation
If you still want to reuse the static file, use current_app.send_static_file() and don't use the transcoding / :
from flask import Flask, current_app app = Flask(__name__) @app.route('/') def hello_world(): return current_app.send_static_file('editor.html')
This looks for the editor.html file directly inside the static folder.
This assumes that you saved the specified file in a folder with a static subtext with the editor.html file inside this subfolder.
Some additional notes:
static_url_path changes to static URL files are available, not the location in the file system used to load data.render_template() assumes your file is a Jinja2 template; if it is really just a static file, then this is overkill and can lead to errors if this file has real executable syntax that has errors or is missing context.
source share