Answer the question
In order to leave comments, you need to log in
How to render html with flask?
All the best!
Sorry for the stupid question, but it doesn't work :( There is a
flask server, located in /user/server_dir/server.py and there is a folder that contains html and css files /usr/other_dir/some_dir/some.html
How to use flask server with /user/server_dir/server.py render /usr/other_dir/some_dir/some.html ?
PS python 2.7
Answer the question
In order to leave comments, you need to log in
1. In the directory with the application, create a templates folder, put html there.
2. In the application (apparently server.py), import the template module: from flask import render_template
3. Next, create the following function for the root directory in the application:
@app.route('/')
def index():
return render_template('index .html')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question