The file index.html
is static, and hence it would be wasteful to pass it through render_template()
. If I store index.html
under static/
and use app = Flask(__name__)
, all is well.
But if I point static_url_path=''
to the root and keep index.html
in the same folder as the Python app, I get
127.0.0.1 - - [21/Nov/2016 14:35:54] "GET / HTTP/1.1" 404 -
index.html
<!DOCTYPE html>
<head></head>
<body>
<h2>Hello, World!</h2>
</body>
.py
from flask import Flask, current_app
app = Flask(__name__, static_url_path='')
@app.route('/')
def hello_world():
return current_app.send_static_file('index.html')
if __name__=="__main__":
app.run()
How do I use a fully flat directory hierarchy, keeping the two files above in the same directory?