flask bootstrap

Step 1: Install Flask and Flask-Bootstrap

pip install Flask Flask-Bootstrap

Step 2: Create a Flask App

from flask import Flask, render_template
from flask_bootstrap import Bootstrap

app = Flask(__name__)
Bootstrap(app)

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

if __name__ == '__main__':
    app.run(debug=True)

Step 3: Create Templates Folder and HTML File - Create a folder named "templates" in the same directory as your main script. - Inside the "templates" folder, create an HTML file (e.g., index.html) with the following content:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Flask Bootstrap Example</title>
    {% block styles %}
        {{ bootstrap.load_css() }}
    {% endblock %}
</head>
<body>
    <div class="container">
        <h1>Hello, Flask Bootstrap!</h1>
    </div>
    {% block scripts %}
        {{ bootstrap.load_js() }}
    {% endblock %}
</body>
</html>

Step 4: Run the Flask App

python your_script_name.py

Visit http://127.0.0.1:5000/ in your web browser to see the Flask app with Bootstrap styling.