I am trying to serve a static html file, but returns a 500 error (a copy of editor.html is on .py and templates directory) This is all I have tried:
from fla
Reducing this to the simplest method that'll work:
static subfolder.static_url_path either./static/ to verify the file worksIf you then still want to reuse a static file, use current_app.send_static_file(), and do not use leading / slashes:
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 file editor.html directly inside the static folder.
This presumes that you saved the above file in a folder that has a static subfolder with a file editor.html inside that subfolder.
Some further notes:
static_url_path changes the URL static files are available at, not the location on the filesystem used to load the data from.render_template() assumes your file is a Jinja2 template; if it is really just a static file then that is overkill and can lead to errors if there is actual executable syntax in that file that has errors or is missing context.