A minimal Flask project with HTML, CSS, and JavaScript ready to go.
flask_template/
├── app.py # Flask application
├── requirements.txt # Python dependencies
├── templates/
│ └── index.html # Main page template
└── static/
├── style.css # Styles
└── script.js # Client-side JavaScript
python -m venv venv
source venv/bin/activate # Linux / macOS
venv\Scripts\activate # Windowspip install -r requirements.txtpython app.pyOpen http://127.0.0.1:5000 in your browser.
| What you want to change | File to edit |
|---|---|
| Page content / structure | templates/index.html |
| Styles | static/style.css |
| Client-side behaviour | static/script.js |
| Routes / backend logic | app.py |
- Create a new template in
templates/, e.g.templates/about.html. - Add a route in
app.py:
@app.route('/about')
def about():
return render_template('about.html')Flask uses Jinja2 for templating. Pass variables from your route:
@app.route('/')
def hello_world():
return render_template('index.html', name='World')Then use them in the HTML:
<h1>Hello, {{ name }}!</h1>