Flask Basics 30 Pages
Flask Basics 30 Pages
Introduction to Flask
Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy,
Installation
app = Flask(__name__)
@app.route('/')
def home():
Routing
@app.route('/about')
def about():
Flask Basics
Template Rendering
Flask supports Jinja2 templates. Create an HTML file and render it:
@app.route('/')
def home():
return render_template('index.html')
Handling Forms
@app.route('/submit', methods=['POST'])
def submit():
name = request.form['name']
return redirect(url_for('home'))
Static Files
Serve CSS, JS, and images from the static folder. Access with /static/filename
Session Management
Flask provides session support using cookies. Set a secret key and use session like a dictionary.
Introduction to Flask
Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy,
Installation
app = Flask(__name__)
@app.route('/')
def home():
Routing
@app.route('/about')
def about():
Template Rendering
Flask supports Jinja2 templates. Create an HTML file and render it:
@app.route('/')
def home():
return render_template('index.html')
Flask Basics
Handling Forms
@app.route('/submit', methods=['POST'])
def submit():
name = request.form['name']
return redirect(url_for('home'))
Static Files
Serve CSS, JS, and images from the static folder. Access with /static/filename
Session Management
Flask Basics
Flask provides session support using cookies. Set a secret key and use session like a dictionary.
Introduction to Flask
Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy,
Installation
app = Flask(__name__)
@app.route('/')
def home():
Routing
@app.route('/about')
def about():
Template Rendering
Flask supports Jinja2 templates. Create an HTML file and render it:
@app.route('/')
def home():
return render_template('index.html')
Handling Forms
@app.route('/submit', methods=['POST'])
def submit():
name = request.form['name']
return redirect(url_for('home'))
Static Files
Serve CSS, JS, and images from the static folder. Access with /static/filename
Session Management
Flask provides session support using cookies. Set a secret key and use session like a dictionary.
Introduction to Flask
Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy,
Installation
app = Flask(__name__)
@app.route('/')
def home():
Routing
@app.route('/about')
def about():
Template Rendering
Flask supports Jinja2 templates. Create an HTML file and render it:
@app.route('/')
def home():
return render_template('index.html')
Flask Basics
Handling Forms
@app.route('/submit', methods=['POST'])
def submit():
name = request.form['name']
return redirect(url_for('home'))
Static Files
Serve CSS, JS, and images from the static folder. Access with /static/filename
Session Management
Flask Basics
Flask provides session support using cookies. Set a secret key and use session like a dictionary.
Introduction to Flask
Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy,
Installation
app = Flask(__name__)
@app.route('/')
def home():
Routing
@app.route('/about')
def about():
Template Rendering
Flask supports Jinja2 templates. Create an HTML file and render it:
@app.route('/')
def home():
return render_template('index.html')
Handling Forms
@app.route('/submit', methods=['POST'])
def submit():
name = request.form['name']
return redirect(url_for('home'))
Static Files
Serve CSS, JS, and images from the static folder. Access with /static/filename
Session Management
Flask provides session support using cookies. Set a secret key and use session like a dictionary.
Introduction to Flask
Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy,
Installation
app = Flask(__name__)
@app.route('/')
def home():
Routing
@app.route('/about')
def about():
Template Rendering
Flask supports Jinja2 templates. Create an HTML file and render it:
@app.route('/')
def home():
return render_template('index.html')
Flask Basics
Handling Forms
@app.route('/submit', methods=['POST'])
def submit():
name = request.form['name']
return redirect(url_for('home'))
Static Files
Serve CSS, JS, and images from the static folder. Access with /static/filename
Session Management
Flask Basics
Flask provides session support using cookies. Set a secret key and use session like a dictionary.
Introduction to Flask
Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy,
Installation
app = Flask(__name__)
@app.route('/')
def home():
Routing
@app.route('/about')
def about():
Template Rendering
Flask supports Jinja2 templates. Create an HTML file and render it:
@app.route('/')
def home():
return render_template('index.html')
Handling Forms
@app.route('/submit', methods=['POST'])
def submit():
name = request.form['name']
return redirect(url_for('home'))
Static Files
Serve CSS, JS, and images from the static folder. Access with /static/filename
Session Management
Flask provides session support using cookies. Set a secret key and use session like a dictionary.
Introduction to Flask
Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy,
Installation
app = Flask(__name__)
@app.route('/')
def home():
Routing
@app.route('/about')
def about():
Template Rendering
Flask supports Jinja2 templates. Create an HTML file and render it:
@app.route('/')
def home():
return render_template('index.html')
Flask Basics
Handling Forms
@app.route('/submit', methods=['POST'])
def submit():
name = request.form['name']
return redirect(url_for('home'))
Static Files
Serve CSS, JS, and images from the static folder. Access with /static/filename
Session Management
Flask Basics
Flask provides session support using cookies. Set a secret key and use session like a dictionary.
Introduction to Flask
Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy,
Installation
app = Flask(__name__)
@app.route('/')
def home():
Routing
@app.route('/about')
def about():
Template Rendering
Flask supports Jinja2 templates. Create an HTML file and render it:
@app.route('/')
def home():
return render_template('index.html')
Handling Forms
@app.route('/submit', methods=['POST'])
def submit():
name = request.form['name']
return redirect(url_for('home'))
Static Files
Serve CSS, JS, and images from the static folder. Access with /static/filename
Session Management
Flask provides session support using cookies. Set a secret key and use session like a dictionary.
Introduction to Flask
Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy,
Installation
app = Flask(__name__)
@app.route('/')
def home():
Routing
@app.route('/about')
def about():
Template Rendering
Flask supports Jinja2 templates. Create an HTML file and render it:
@app.route('/')
def home():
return render_template('index.html')
Flask Basics
Handling Forms
@app.route('/submit', methods=['POST'])
def submit():
name = request.form['name']
return redirect(url_for('home'))
Static Files
Serve CSS, JS, and images from the static folder. Access with /static/filename
Session Management
Flask Basics
Flask provides session support using cookies. Set a secret key and use session like a dictionary.
Introduction to Flask
Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy,
Installation
app = Flask(__name__)
@app.route('/')
def home():
Routing
@app.route('/about')
def about():
Template Rendering
Flask supports Jinja2 templates. Create an HTML file and render it:
@app.route('/')
def home():
return render_template('index.html')
Handling Forms
@app.route('/submit', methods=['POST'])
def submit():
name = request.form['name']
return redirect(url_for('home'))
Static Files
Serve CSS, JS, and images from the static folder. Access with /static/filename
Session Management
Flask provides session support using cookies. Set a secret key and use session like a dictionary.
Introduction to Flask
Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy,
Installation
app = Flask(__name__)
@app.route('/')
def home():
Routing
@app.route('/about')
def about():
Template Rendering
Flask supports Jinja2 templates. Create an HTML file and render it:
@app.route('/')
def home():
return render_template('index.html')
Flask Basics
Handling Forms
@app.route('/submit', methods=['POST'])
def submit():
name = request.form['name']