Outils pour utilisateurs

Outils du site


Panneau latéral

Plan du Site:

python:flask:blueprints

Organiser l'application grâce aux Blueprints

Tutorial : https://www.youtube.com/watch?v=wC3qkE5vD4M

/home/marc/flaskapp
├── app
│   ├── section1
│   │   ├── __init__.py
│   │   └── ...
│   │
│   ├── section2
│   │   ├── __init__.py
│   │   └── ...
│   │
│   ├── templates
│   │   ├── section1
│   │   │   ├── home.html
│   │   │   └── ...
│   │   │
│   │   ├── section2
│   │   │   ├── home.html
│   │   │   └── ...
│   │   │
│   │   └── base.html
│   │
│   ├── __init__.py
│   ├── ...
│   ├── home.py
│   └── ...
├── run.py
└── ...

home

app/home.py
from flask import Blueprint, render_template
 
home = Blueprint("home", __name__)
 
@home.route("/home")
def home_page():
    return render_template("index.html")

__init__.py

app/__init__.py
from flask import Flask
from app.home import home
 
app = Flask(__name__)
app.register_blueprint(home)

run.py

run.py
from app import app
app.run(host="0.0.0.0", port=8000, debug=True)
python/flask/blueprints.txt · Dernière modification: 2021/08/29 06:25 par marclebrun