how to return an html file in flask

from flask import Flask, render_template

app = Flask(__name__)

@app.route('/')
def index():
    return render_template('index.html')

if __name__ == '__main__':
    app.run(debug=True)
  1. Import the Flask class and render_template function from the Flask module.
  2. Create a Flask application instance with Flask(__name__).
  3. Define a route for the root URL '/' using the @app.route decorator.
  4. Create a function (e.g., index()) to handle the specified route.
  5. Inside the function, use render_template('index.html') to render the HTML file named 'index.html'.
  6. If the script is run directly (not imported), start the Flask development server with app.run(debug=True).