Issue
I want to know how to output in the screen an html file. I have a route function and i want to display html to a website
@app.route('/')
def index():
return "hi"
Solution
Welcome to stack overflow!
To render an html template in flask first you must create a folder named templates
. The folder must be in the same directory as your main file (where the app runs)
Then create a html file in the templates folder. You can call it whatever you want, I will call it index.html
Then add this code to your route:
from Flask import render_template
@app.route('/')
def index():
return render_template('index.html')
Answered By - OlauPla
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.